diff --git a/lib/check.h b/lib/check.h index c11eb8f5d..f5e5d6370 100644 --- a/lib/check.h +++ b/lib/check.h @@ -39,16 +39,16 @@ class Check { public: /** This constructor is used when registering the CheckClass */ - Check() - : _tokenizer(0), _settings(0), _errorLogger(0) + Check(const std::string &aname) + : _name(aname), _tokenizer(0), _settings(0), _errorLogger(0) { instances().push_back(this); instances().sort(); } /** This constructor is used when running checks. */ - Check(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger) + Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) + : _name(aname), _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger) { } virtual ~Check() @@ -98,7 +98,10 @@ public: virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) = 0; /** class name, used to generate documentation */ - virtual std::string name() const = 0; + std::string name() const + { + return _name; + } /** get information about this class, used to generate documentation */ virtual std::string classInfo() const = 0; @@ -114,6 +117,7 @@ public: } protected: + const std::string _name; const Tokenizer * const _tokenizer; const Settings * const _settings; ErrorLogger * const _errorLogger; diff --git a/lib/checkautovariables.h b/lib/checkautovariables.h index 97df17ccf..a1faf1450 100644 --- a/lib/checkautovariables.h +++ b/lib/checkautovariables.h @@ -34,12 +34,12 @@ class CheckAutoVariables : public Check { public: /** This constructor is used when registering the CheckClass */ - CheckAutoVariables() : Check() + CheckAutoVariables() : Check(myName()) { } /** This constructor is used when running checks. */ CheckAutoVariables(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) @@ -98,7 +98,7 @@ private: c.errorReturnTempPointer(0); } - std::string name() const + std::string myName() const { return "Auto Variables"; } diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index c2e77a20b..fe8ca2645 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -50,12 +50,12 @@ class CheckBufferOverrun : public Check public: /** This constructor is used when registering the CheckClass */ - CheckBufferOverrun() : Check() + CheckBufferOverrun() : Check(myName()) { } /** This constructor is used when running checks. */ CheckBufferOverrun(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) @@ -209,7 +209,7 @@ public: c.pointerOutOfBounds(0, "array"); } - std::string name() const + std::string myName() const { return "Bounds checking"; } diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index fc96af0cc..0991e795f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -42,7 +42,7 @@ CheckClass instance; //--------------------------------------------------------------------------- CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger), + : Check(myName(), tokenizer, settings, errorLogger), symbolDatabase(NULL) { diff --git a/lib/checkclass.h b/lib/checkclass.h index dd5f15883..cc550c36b 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -36,7 +36,7 @@ class CheckClass : public Check { public: /** @brief This constructor is used when registering the CheckClass */ - CheckClass() : Check(), symbolDatabase(NULL) + CheckClass() : Check(myName()), symbolDatabase(NULL) { } /** @brief This constructor is used when running checks. */ @@ -144,7 +144,7 @@ private: c.checkConstError(0, "class", "function"); } - std::string name() const + std::string myName() const { return "Class"; } diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index 584cf78d6..af92597f5 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -43,12 +43,12 @@ class CheckExceptionSafety : public Check { public: /** This constructor is used when registering the CheckClass */ - CheckExceptionSafety() : Check() + CheckExceptionSafety() : Check(myName()) { } /** This constructor is used when running checks. */ CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } /** Checks that uses the simplified token list */ @@ -86,7 +86,7 @@ private: } /** Short description of class (for --doc) */ - std::string name() const + std::string myName() const { return "Exception Safety"; } diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index d535ea4cb..7ba6a53b4 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -172,12 +172,12 @@ class CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak { public: /** @brief This constructor is used when registering this class */ - CheckMemoryLeakInFunction() : Check(), CheckMemoryLeak(0, 0), symbolDatabase(NULL) + CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(0, 0), symbolDatabase(NULL) { } /** @brief This constructor is used when running checks */ CheckMemoryLeakInFunction(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) - : Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) + : Check(myName(), tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) { // get the symbol database if (tokenizr) @@ -329,7 +329,7 @@ public: * Get name of class (--doc) * @return name of class */ - std::string name() const + std::string myName() const { return "Memory leaks (function variables)"; } @@ -364,11 +364,11 @@ public: class CheckMemoryLeakInClass : private Check, private CheckMemoryLeak { public: - CheckMemoryLeakInClass() : Check(), CheckMemoryLeak(0, 0) + CheckMemoryLeakInClass() : Check(myName()), CheckMemoryLeak(0, 0) { } CheckMemoryLeakInClass(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) - : Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) + : Check(myName(), tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) { } void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) @@ -396,7 +396,7 @@ private: void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) { } - std::string name() const + std::string myName() const { return "Memory leaks (class variables)"; } @@ -414,11 +414,11 @@ private: class CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak { public: - CheckMemoryLeakStructMember() : Check(), CheckMemoryLeak(0, 0) + CheckMemoryLeakStructMember() : Check(myName()), CheckMemoryLeak(0, 0) { } CheckMemoryLeakStructMember(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) - : Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) + : Check(myName(), tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) { } void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) @@ -434,7 +434,7 @@ private: void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) { } - std::string name() const + std::string myName() const { return "Memory leaks (struct members)"; } @@ -452,11 +452,11 @@ private: class CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak { public: - CheckMemoryLeakNoVar() : Check(), CheckMemoryLeak(0, 0) + CheckMemoryLeakNoVar() : Check(myName()), CheckMemoryLeak(0, 0) { } CheckMemoryLeakNoVar(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) - : Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) + : Check(myName(), tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog) { } void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) @@ -474,7 +474,7 @@ private: void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) { } - std::string name() const + std::string myName() const { return "Memory leaks (address not taken)"; } diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index c1b134e91..1f23bcf87 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -37,12 +37,12 @@ class CheckNullPointer : public Check { public: /** @brief This constructor is used when registering the CheckNullPointer */ - CheckNullPointer() : Check() + CheckNullPointer() : Check(myName()) { } /** @brief This constructor is used when running checks. */ CheckNullPointer(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } /** @brief Run checks against the normal token list */ @@ -112,7 +112,7 @@ public: } /** Name of check */ - std::string name() const + std::string myName() const { return "Null pointer"; } diff --git a/lib/checkobsoletefunctions.h b/lib/checkobsoletefunctions.h index 3ee4f88f3..706803aa8 100644 --- a/lib/checkobsoletefunctions.h +++ b/lib/checkobsoletefunctions.h @@ -38,14 +38,14 @@ class CheckObsoleteFunctions : public Check { public: /** This constructor is used when registering the CheckObsoleteFunctions */ - CheckObsoleteFunctions() : Check() + CheckObsoleteFunctions() : Check(myName()) { initObsoleteFunctions(); } /** This constructor is used when running checks. */ CheckObsoleteFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { initObsoleteFunctions(); } @@ -125,7 +125,7 @@ private: } } - std::string name() const + std::string myName() const { return "Obsolete functions"; } diff --git a/lib/checkother.h b/lib/checkother.h index bace5a82e..bc5b1db35 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -37,12 +37,12 @@ class CheckOther : public Check { public: /** @brief This constructor is used when registering the CheckClass */ - CheckOther() : Check() + CheckOther() : Check(myName()) { } /** @brief This constructor is used when running checks. */ CheckOther(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } /** @brief Run checks against the normal token list */ @@ -245,7 +245,7 @@ public: c.clarifyCalculationError(0); } - std::string name() const + std::string myName() const { return "Other"; } diff --git a/lib/checkpostfixoperator.h b/lib/checkpostfixoperator.h index 2840df19e..e7e4651fb 100644 --- a/lib/checkpostfixoperator.h +++ b/lib/checkpostfixoperator.h @@ -35,12 +35,12 @@ class CheckPostfixOperator : public Check { public: /** This constructor is used when registering the CheckPostfixOperator */ - CheckPostfixOperator() : Check() + CheckPostfixOperator() : Check(myName()) { } /** This constructor is used when running checks. */ CheckPostfixOperator(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) @@ -62,7 +62,7 @@ private: c.postfixOperatorError(0); } - std::string name() const + std::string myName() const { return "Using postfix operators"; } diff --git a/lib/checkstl.h b/lib/checkstl.h index e232eedcd..ebd6938b1 100644 --- a/lib/checkstl.h +++ b/lib/checkstl.h @@ -35,12 +35,12 @@ class CheckStl : public Check { public: /** This constructor is used when registering the CheckClass */ - CheckStl() : Check() + CheckStl() : Check(myName()) { } /** This constructor is used when running checks. */ CheckStl(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } /** Simplified checks. The token list is simplified. */ @@ -173,7 +173,7 @@ private: c.redundantIfRemoveError(0); } - std::string name() const + std::string myName() const { return "STL usage"; } diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index 78465d821..8ab4844ed 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -37,12 +37,12 @@ class CheckUninitVar : public Check { public: /** @brief This constructor is used when registering the CheckUninitVar */ - CheckUninitVar() : Check() + CheckUninitVar() : Check(myName()) { } /** @brief This constructor is used when running checks. */ CheckUninitVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } /** @brief Run checks against the normal token list */ @@ -87,7 +87,7 @@ public: c.uninitvarError(0, "varname"); } - std::string name() const + std::string myName() const { return "Uninitialized variables"; } diff --git a/lib/checkunusedfunctions.h b/lib/checkunusedfunctions.h index 066faafd6..6d408bcdb 100644 --- a/lib/checkunusedfunctions.h +++ b/lib/checkunusedfunctions.h @@ -33,12 +33,12 @@ class CheckUnusedFunctions: public Check { public: /** @brief This constructor is used when registering the CheckUnusedFunctions */ - CheckUnusedFunctions() : Check() + CheckUnusedFunctions() : Check(myName()) { } /** @brief This constructor is used when running checks. */ CheckUnusedFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : Check(tokenizer, settings, errorLogger) + : Check(myName(), tokenizer, settings, errorLogger) { } // Parse current tokens and determine.. @@ -69,7 +69,7 @@ private: } - std::string name() const + std::string myName() const { return "Unused functions"; }