From 9367be804e11c800b1865d11880396b6999722e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Tue, 7 Jun 2022 21:25:23 +0200 Subject: [PATCH] fixed `modernize-use-equals-delete` warnings in headers (#4177) --- lib/check.h | 6 +++--- lib/checkio.h | 7 +++---- lib/timer.h | 7 ++++--- lib/token.h | 7 +++---- lib/tokenlist.h | 10 +++------- test/options.h | 7 +++---- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/lib/check.h b/lib/check.h index cd47c0b84..9a440d126 100644 --- a/lib/check.h +++ b/lib/check.h @@ -69,6 +69,9 @@ public: instances().remove(this); } + Check(const Check &) = delete; + Check& operator=(const Check &) = delete; + /** List of registered check classes. This is used by Cppcheck to run checks and generate documentation */ static std::list &instances(); @@ -159,9 +162,6 @@ protected: */ bool wrongData(const Token *tok, const char *str); - /** disabled assignment operator and copy constructor */ - void operator=(const Check &) = delete; - Check(const Check &) = delete; private: const std::string mName; }; diff --git a/lib/checkio.h b/lib/checkio.h index 633e50b4c..e660f9832 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -76,6 +76,9 @@ private: ArgumentInfo(const Token *arg, const Settings *settings, bool _isCPP); ~ArgumentInfo(); + ArgumentInfo(const ArgumentInfo &) = delete; + ArgumentInfo& operator= (const ArgumentInfo &) = delete; + bool isArrayOrPointer() const; bool isComplexType() const; bool isKnownType() const; @@ -91,10 +94,6 @@ private: bool _template; bool address; bool isCPP; - - private: - ArgumentInfo(const ArgumentInfo &); // not implemented - ArgumentInfo operator = (const ArgumentInfo &); // not implemented }; void checkFormatString(const Token * const tok, diff --git a/lib/timer.h b/lib/timer.h index 78267114f..9b00e833e 100644 --- a/lib/timer.h +++ b/lib/timer.h @@ -69,12 +69,13 @@ class CPPCHECKLIB Timer { public: Timer(const std::string& str, SHOWTIME_MODES showtimeMode, TimerResultsIntf* timerResults = nullptr); ~Timer(); + + Timer(const Timer&) = delete; + Timer& operator=(const Timer&) = delete; + void stop(); private: - Timer(const Timer& other); // disallow copying - Timer& operator=(const Timer&); // disallow assignments - const std::string mStr; TimerResultsIntf* mTimerResults; std::clock_t mStart; diff --git a/lib/token.h b/lib/token.h index 324eceaa5..f4e449528 100644 --- a/lib/token.h +++ b/lib/token.h @@ -179,11 +179,10 @@ class CPPCHECKLIB Token { private: TokensFrontBack* mTokensFrontBack; - // Not implemented.. - Token(const Token &); - Token operator=(const Token &); - public: + Token(const Token &) = delete; + Token& operator=(const Token &) = delete; + enum Type { eVariable, eType, eFunction, eKeyword, eName, // Names: Variable (varId), Type (typeId, later), Function (FuncId, later), Language keyword, Name (unknown identifier) eNumber, eString, eChar, eBoolean, eLiteral, eEnumerator, // Literals: Number, String, Character, Boolean, User defined literal (C++11), Enumerator diff --git a/lib/tokenlist.h b/lib/tokenlist.h index f011db505..d0cf2b068 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -43,6 +43,9 @@ public: explicit TokenList(const Settings* settings); ~TokenList(); + TokenList(const TokenList &) = delete; + TokenList &operator=(const TokenList &) = delete; + void setSettings(const Settings *settings) { mSettings = settings; } @@ -192,13 +195,6 @@ public: bool isKeyword(const std::string &str) const; private: - - /** Disable copy constructor, no implementation */ - TokenList(const TokenList &); - - /** Disable assignment operator, no implementation */ - TokenList &operator=(const TokenList &); - void determineCppC(); /** Token list */ diff --git a/test/options.h b/test/options.h index 9beaf37be..7f772d1f1 100644 --- a/test/options.h +++ b/test/options.h @@ -38,10 +38,9 @@ public: const std::string& exe() const; -private: - options(); - options(const options& non_copy); - const options& operator =(const options& non_assign); + options() = delete; + options(const options&) = delete; + options& operator =(const options&) = delete; private: std::set mWhichTests;