Introduce macro OVERRIDE for gcc-4.6 compatibility.

This commit is contained in:
Daniel Marjamäki 2019-01-12 07:37:42 +01:00
parent bae4040060
commit 8b5f36670a
31 changed files with 129 additions and 122 deletions

View File

@ -52,13 +52,13 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
Check64BitPortability check64BitPortability(tokenizer, settings, errorLogger); Check64BitPortability check64BitPortability(tokenizer, settings, errorLogger);
check64BitPortability.pointerassignment(); check64BitPortability.pointerassignment();
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer; (void)tokenizer;
(void)settings; (void)settings;
(void)errorLogger; (void)errorLogger;
@ -74,7 +74,7 @@ private:
void returnIntegerError(const Token *tok); void returnIntegerError(const Token *tok);
void returnPointerError(const Token *tok); void returnPointerError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
Check64BitPortability c(nullptr, settings, errorLogger); Check64BitPortability c(nullptr, settings, errorLogger);
c.assignmentAddressToIntegerError(nullptr); c.assignmentAddressToIntegerError(nullptr);
c.assignmentIntegerToAddressError(nullptr); c.assignmentIntegerToAddressError(nullptr);
@ -86,7 +86,7 @@ private:
return "64-bit portability"; return "64-bit portability";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check if there is 64-bit portability issues:\n" return "Check if there is 64-bit portability issues:\n"
"- assign address to/from int/long\n" "- assign address to/from int/long\n"
"- casting address from/to integer when returning from function\n"; "- casting address from/to integer when returning from function\n";

View File

@ -49,7 +49,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckAssert check(tokenizer, settings, errorLogger); CheckAssert check(tokenizer, settings, errorLogger);
check.assertWithSideEffects(); check.assertWithSideEffects();
} }
@ -64,7 +64,7 @@ private:
void sideEffectInAssertError(const Token *tok, const std::string& functionName); void sideEffectInAssertError(const Token *tok, const std::string& functionName);
void assignmentInAssertError(const Token *tok, const std::string &varname); void assignmentInAssertError(const Token *tok, const std::string &varname);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckAssert c(nullptr, settings, errorLogger); CheckAssert c(nullptr, settings, errorLogger);
c.sideEffectInAssertError(nullptr, "function"); c.sideEffectInAssertError(nullptr, "function");
c.assignmentInAssertError(nullptr, "var"); c.assignmentInAssertError(nullptr, "var");
@ -74,7 +74,7 @@ private:
return "Assert"; return "Assert";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Warn if there are side effects in assert statements (since this cause different behaviour in debug/release builds).\n"; return "Warn if there are side effects in assert statements (since this cause different behaviour in debug/release builds).\n";
} }
}; };

View File

@ -49,14 +49,14 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckAutoVariables checkAutoVariables(tokenizer, settings, errorLogger); CheckAutoVariables checkAutoVariables(tokenizer, settings, errorLogger);
checkAutoVariables.assignFunctionArg(); checkAutoVariables.assignFunctionArg();
checkAutoVariables.returnReference(); checkAutoVariables.returnReference();
checkAutoVariables.checkVarLifetime(); checkAutoVariables.checkVarLifetime();
} }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckAutoVariables checkAutoVariables(tokenizer, settings, errorLogger); CheckAutoVariables checkAutoVariables(tokenizer, settings, errorLogger);
checkAutoVariables.autoVariables(); checkAutoVariables.autoVariables();
} }
@ -98,7 +98,7 @@ private:
void errorUselessAssignmentArg(const Token *tok); void errorUselessAssignmentArg(const Token *tok);
void errorUselessAssignmentPtrArg(const Token *tok); void errorUselessAssignmentPtrArg(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckAutoVariables c(nullptr,settings,errorLogger); CheckAutoVariables c(nullptr,settings,errorLogger);
c.errorAutoVariableAssignment(nullptr, false); c.errorAutoVariableAssignment(nullptr, false);
c.errorReturnAddressToAutoVariable(nullptr); c.errorReturnAddressToAutoVariable(nullptr);
@ -119,7 +119,7 @@ private:
return "Auto Variables"; return "Auto Variables";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "A pointer to a variable is only valid as long as the variable is in scope.\n" return "A pointer to a variable is only valid as long as the variable is in scope.\n"
"Check:\n" "Check:\n"
"- returning a pointer to auto or temporary variable\n" "- returning a pointer to auto or temporary variable\n"

View File

@ -50,7 +50,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckBool checkBool(tokenizer, settings, errorLogger); CheckBool checkBool(tokenizer, settings, errorLogger);
// Checks // Checks
@ -62,7 +62,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckBool checkBool(tokenizer, settings, errorLogger); CheckBool checkBool(tokenizer, settings, errorLogger);
// Checks // Checks
@ -118,7 +118,7 @@ private:
void pointerArithBoolError(const Token *tok); void pointerArithBoolError(const Token *tok);
void returnValueBoolError(const Token *tok); void returnValueBoolError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckBool c(nullptr, settings, errorLogger); CheckBool c(nullptr, settings, errorLogger);
c.assignBoolToPointerError(nullptr); c.assignBoolToPointerError(nullptr);
@ -138,7 +138,7 @@ private:
return "Boolean"; return "Boolean";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Boolean type checks\n" return "Boolean type checks\n"
"- using increment on boolean\n" "- using increment on boolean\n"
"- comparison of a boolean expression with an integer other than 0 or 1\n" "- comparison of a boolean expression with an integer other than 0 or 1\n"

View File

@ -49,7 +49,7 @@ public:
} }
/** Simplified checks. The token list is simplified. */ /** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (!tokenizer->isCPP()) if (!tokenizer->isCPP())
return; return;
@ -64,7 +64,7 @@ public:
private: private:
void boostForeachError(const Token *tok); void boostForeachError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckBoost c(nullptr, settings, errorLogger); CheckBoost c(nullptr, settings, errorLogger);
c.boostForeachError(nullptr); c.boostForeachError(nullptr);
} }
@ -73,7 +73,7 @@ private:
return "Boost usage"; return "Boost usage";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check for invalid usage of Boost:\n" return "Check for invalid usage of Boost:\n"
"- container modification during BOOST_FOREACH\n"; "- container modification during BOOST_FOREACH\n";
} }

View File

@ -73,7 +73,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger); CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger);
checkBufferOverrun.checkGlobalAndLocalVariable(); checkBufferOverrun.checkGlobalAndLocalVariable();
if (tokenizer && tokenizer->isMaxTime()) if (tokenizer && tokenizer->isMaxTime())
@ -85,7 +85,7 @@ public:
checkBufferOverrun.negativeArraySize(); checkBufferOverrun.negativeArraySize();
} }
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger); CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger);
checkBufferOverrun.bufferOverrun(); checkBufferOverrun.bufferOverrun();
checkBufferOverrun.checkStringArgument(); checkBufferOverrun.checkStringArgument();
@ -222,7 +222,7 @@ public:
/* data for multifile checking */ /* data for multifile checking */
class MyFileInfo : public Check::FileInfo { class MyFileInfo : public Check::FileInfo {
public: public:
std::string toString() const override; std::string toString() const OVERRIDE;
struct ArrayUsage { struct ArrayUsage {
MathLib::bigint index; MathLib::bigint index;
@ -238,12 +238,12 @@ public:
}; };
/** @brief Parse current TU and extract file info */ /** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const OVERRIDE;
Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override; Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const OVERRIDE;
/** @brief Analyse all file infos for all TU */ /** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) OVERRIDE;
/** /**
* Calculates sizeof value for given type. * Calculates sizeof value for given type.
@ -275,7 +275,7 @@ private:
void valueFlowCheckArrayIndex(const Token * const tok, const ArrayInfo &arrayInfo); void valueFlowCheckArrayIndex(const Token * const tok, const ArrayInfo &arrayInfo);
public: public:
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckBufferOverrun c(nullptr, settings, errorLogger); CheckBufferOverrun c(nullptr, settings, errorLogger);
const std::vector<MathLib::bigint> indexes(2, 1); const std::vector<MathLib::bigint> indexes(2, 1);
c.arrayIndexOutOfBoundsError(nullptr, ArrayInfo(0, "array", 1, 2), indexes); c.arrayIndexOutOfBoundsError(nullptr, ArrayInfo(0, "array", 1, 2), indexes);
@ -301,7 +301,7 @@ private:
return "Bounds checking"; return "Bounds checking";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Out of bounds checking:\n" return "Out of bounds checking:\n"
"- Array index out of bounds detection by value flow analysis\n" "- Array index out of bounds detection by value flow analysis\n"
"- Dangerous usage of strncat()\n" "- Dangerous usage of strncat()\n"

View File

@ -53,7 +53,7 @@ public:
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger); CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
/** @brief Run checks on the normal token list */ /** @brief Run checks on the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())
return; return;
@ -65,7 +65,7 @@ public:
} }
/** @brief Run checks on the simplified token list */ /** @brief Run checks on the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())
return; return;
@ -198,7 +198,7 @@ private:
void unsafeClassDivZeroError(const Token *tok, const std::string &className, const std::string &methodName, const std::string &varName); void unsafeClassDivZeroError(const Token *tok, const std::string &className, const std::string &methodName, const std::string &varName);
void overrideError(const Function *funcInBase, const Function *funcInDerived); void overrideError(const Function *funcInBase, const Function *funcInDerived);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckClass c(nullptr, settings, errorLogger); CheckClass c(nullptr, settings, errorLogger);
c.noConstructorError(nullptr, "classname", false); c.noConstructorError(nullptr, "classname", false);
c.noExplicitConstructorError(nullptr, "classname", false); c.noExplicitConstructorError(nullptr, "classname", false);
@ -240,7 +240,7 @@ private:
return "Class"; return "Class";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check the code for each class.\n" return "Check the code for each class.\n"
"- Missing constructors and copy constructors\n" "- Missing constructors and copy constructors\n"
//"- Missing allocation of memory in copy constructor\n" //"- Missing allocation of memory in copy constructor\n"

View File

@ -51,7 +51,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckCondition checkCondition(tokenizer, settings, errorLogger); CheckCondition checkCondition(tokenizer, settings, errorLogger);
checkCondition.multiCondition(); checkCondition.multiCondition();
checkCondition.clarifyCondition(); // not simplified because ifAssign checkCondition.clarifyCondition(); // not simplified because ifAssign
@ -64,7 +64,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckCondition checkCondition(tokenizer, settings, errorLogger); CheckCondition checkCondition(tokenizer, settings, errorLogger);
checkCondition.assignIf(); checkCondition.assignIf();
checkCondition.checkBadBitmaskCheck(); checkCondition.checkBadBitmaskCheck();
@ -156,7 +156,7 @@ private:
void invalidTestForOverflow(const Token* tok, bool result); void invalidTestForOverflow(const Token* tok, bool result);
void pointerAdditionResultNotNullError(const Token *tok, const Token *calc); void pointerAdditionResultNotNullError(const Token *tok, const Token *calc);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckCondition c(nullptr, settings, errorLogger); CheckCondition c(nullptr, settings, errorLogger);
ErrorPath errorPath; ErrorPath errorPath;
@ -183,7 +183,7 @@ private:
return "Condition"; return "Condition";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Match conditions with assignments and other conditions:\n" return "Match conditions with assignments and other conditions:\n"
"- Mismatching assignment and comparison => comparison is always true/false\n" "- Mismatching assignment and comparison => comparison is always true/false\n"
"- Mismatching lhs and rhs in comparison => comparison is always true/false\n" "- Mismatching lhs and rhs in comparison => comparison is always true/false\n"

View File

@ -62,7 +62,7 @@ public:
} }
/** Checks that uses the simplified token list */ /** Checks that uses the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())
return; return;
@ -137,7 +137,7 @@ private:
} }
/** Generate all possible errors (for --errorlist) */ /** Generate all possible errors (for --errorlist) */
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckExceptionSafety c(nullptr, settings, errorLogger); CheckExceptionSafety c(nullptr, settings, errorLogger);
c.destructorsError(nullptr, "Class"); c.destructorsError(nullptr, "Class");
c.deallocThrowError(nullptr, "p"); c.deallocThrowError(nullptr, "p");
@ -153,7 +153,7 @@ private:
} }
/** wiki formatted description of the class (for --doc) */ /** wiki formatted description of the class (for --doc) */
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Checking exception safety\n" return "Checking exception safety\n"
"- Throwing exceptions in destructors\n" "- Throwing exceptions in destructors\n"
"- Throwing exception during invalid state\n" "- Throwing exception during invalid state\n"

View File

@ -58,7 +58,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckFunctions checkFunctions(tokenizer, settings, errorLogger); CheckFunctions checkFunctions(tokenizer, settings, errorLogger);
// Checks // Checks
@ -69,7 +69,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckFunctions checkFunctions(tokenizer, settings, errorLogger); CheckFunctions checkFunctions(tokenizer, settings, errorLogger);
checkFunctions.checkProhibitedFunctions(); checkFunctions.checkProhibitedFunctions();
@ -118,7 +118,7 @@ private:
void memsetFloatError(const Token *tok, const std::string &var_value); void memsetFloatError(const Token *tok, const std::string &var_value);
void memsetValueOutOfRangeError(const Token *tok, const std::string &value); void memsetValueOutOfRangeError(const Token *tok, const std::string &value);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckFunctions c(nullptr, settings, errorLogger); CheckFunctions c(nullptr, settings, errorLogger);
for (std::map<std::string, Library::WarnInfo>::const_iterator i = settings->library.functionwarn.cbegin(); i != settings->library.functionwarn.cend(); ++i) { for (std::map<std::string, Library::WarnInfo>::const_iterator i = settings->library.functionwarn.cbegin(); i != settings->library.functionwarn.cend(); ++i) {
@ -140,7 +140,7 @@ private:
return "Check function usage"; return "Check function usage";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check function usage:\n" return "Check function usage:\n"
"- return value of certain functions not used\n" "- return value of certain functions not used\n"
"- invalid input values for functions\n" "- invalid input values for functions\n"

View File

@ -44,7 +44,7 @@ public:
} }
/** Simplified checks. The token list is simplified. */ /** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (!settings->isEnabled(Settings::INTERNAL)) if (!settings->isEnabled(Settings::INTERNAL))
return; return;
@ -94,7 +94,7 @@ private:
void extraWhitespaceError(const Token *tok, const std::string &pattern, const std::string &funcname); void extraWhitespaceError(const Token *tok, const std::string &pattern, const std::string &funcname);
void checkRedundantTokCheckError(const Token *tok); void checkRedundantTokCheckError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckInternal c(nullptr, settings, errorLogger); CheckInternal c(nullptr, settings, errorLogger);
c.multiComparePatternError(nullptr, ";|%type%", "Match"); c.multiComparePatternError(nullptr, ";|%type%", "Match");
c.simplePatternError(nullptr, "class {", "Match"); c.simplePatternError(nullptr, "class {", "Match");
@ -111,7 +111,7 @@ private:
return "cppcheck internal API usage"; return "cppcheck internal API usage";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
// Don't include these checks on the WIKI where people can read what // Don't include these checks on the WIKI where people can read what
// checks there are. These checks are not intended for users. // checks there are. These checks are not intended for users.
return ""; return "";

View File

@ -50,14 +50,14 @@ public:
} }
/** @brief Run checks on the normal token list */ /** @brief Run checks on the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckIO checkIO(tokenizer, settings, errorLogger); CheckIO checkIO(tokenizer, settings, errorLogger);
checkIO.checkWrongPrintfScanfArguments(); checkIO.checkWrongPrintfScanfArguments();
} }
/** @brief Run checks on the simplified token list */ /** @brief Run checks on the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckIO checkIO(tokenizer, settings, errorLogger); CheckIO checkIO(tokenizer, settings, errorLogger);
checkIO.checkCoutCerrMisusage(); checkIO.checkCoutCerrMisusage();
@ -139,7 +139,7 @@ private:
static void argumentType(std::ostream & os, const ArgumentInfo * argInfo); static void argumentType(std::ostream & os, const ArgumentInfo * argInfo);
static Severity::SeverityType getSeverity(const ArgumentInfo *argInfo); static Severity::SeverityType getSeverity(const ArgumentInfo *argInfo);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckIO c(nullptr, settings, errorLogger); CheckIO c(nullptr, settings, errorLogger);
c.coutCerrMisusageError(nullptr, "cout"); c.coutCerrMisusageError(nullptr, "cout");
@ -170,7 +170,7 @@ private:
return "IO using format string"; return "IO using format string";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check format string input/output operations.\n" return "Check format string input/output operations.\n"
"- Bad usage of the function 'sprintf' (overlapping data)\n" "- Bad usage of the function 'sprintf' (overlapping data)\n"
"- Missing or wrong width specifiers in 'scanf' format string\n" "- Missing or wrong width specifiers in 'scanf' format string\n"

View File

@ -104,7 +104,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger); CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger);
checkLeakAutoVar.check(); checkLeakAutoVar.check();
} }
@ -147,7 +147,7 @@ private:
/** message: user configuration is needed to complete analysis */ /** message: user configuration is needed to complete analysis */
void configurationInfo(const Token* tok, const std::string &functionName); void configurationInfo(const Token* tok, const std::string &functionName);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckLeakAutoVar c(nullptr, settings, errorLogger); CheckLeakAutoVar c(nullptr, settings, errorLogger);
c.deallocReturnError(nullptr, "p"); c.deallocReturnError(nullptr, "p");
c.configurationInfo(nullptr, "f"); // user configuration is needed to complete analysis c.configurationInfo(nullptr, "f"); // user configuration is needed to complete analysis
@ -158,7 +158,7 @@ private:
return "Leaks (auto variables)"; return "Leaks (auto variables)";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Detect when a auto variable is allocated but not deallocated or deallocated twice.\n"; return "Detect when a auto variable is allocated but not deallocated or deallocated twice.\n";
} }
}; };

View File

@ -184,7 +184,7 @@ public:
} }
/** @brief run all simplified checks */ /** @brief run all simplified checks */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.checkReallocUsage(); checkMemoryLeak.checkReallocUsage();
} }
@ -199,7 +199,7 @@ public:
private: private:
/** Report all possible errors (for the --errorlist) */ /** Report all possible errors (for the --errorlist) */
void getErrorMessages(ErrorLogger *e, const Settings *settings) const override { void getErrorMessages(ErrorLogger *e, const Settings *settings) const OVERRIDE {
CheckMemoryLeakInFunction c(nullptr, settings, e); CheckMemoryLeakInFunction c(nullptr, settings, e);
c.memleakError(nullptr, "varname"); c.memleakError(nullptr, "varname");
@ -225,7 +225,7 @@ private:
* Get class information (--doc) * Get class information (--doc)
* @return Wiki formatted information about this class * @return Wiki formatted information about this class
*/ */
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Is there any allocated memory when a function goes out of scope\n"; return "Is there any allocated memory when a function goes out of scope\n";
} }
}; };
@ -245,7 +245,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
} }
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) override { void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) OVERRIDE {
if (!tokenizr->isCPP()) if (!tokenizr->isCPP())
return; return;
@ -264,7 +264,7 @@ private:
void unsafeClassError(const Token *tok, const std::string &classname, const std::string &varname); void unsafeClassError(const Token *tok, const std::string &classname, const std::string &varname);
void getErrorMessages(ErrorLogger *e, const Settings *settings) const override { void getErrorMessages(ErrorLogger *e, const Settings *settings) const OVERRIDE {
CheckMemoryLeakInClass c(nullptr, settings, e); CheckMemoryLeakInClass c(nullptr, settings, e);
c.publicAllocationError(nullptr, "varname"); c.publicAllocationError(nullptr, "varname");
c.unsafeClassError(nullptr, "class", "class::varname"); c.unsafeClassError(nullptr, "class", "class::varname");
@ -274,7 +274,7 @@ private:
return "Memory leaks (class variables)"; return "Memory leaks (class variables)";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "If the constructor allocate memory then the destructor must deallocate it.\n"; return "If the constructor allocate memory then the destructor must deallocate it.\n";
} }
}; };
@ -292,7 +292,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
} }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakStructMember checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakStructMember checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.check(); checkMemoryLeak.check();
} }
@ -306,14 +306,14 @@ private:
void checkStructVariable(const Variable * const variable); void checkStructVariable(const Variable * const variable);
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const override { void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const OVERRIDE {
} }
static std::string myName() { static std::string myName() {
return "Memory leaks (struct members)"; return "Memory leaks (struct members)";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Don't forget to deallocate struct members\n"; return "Don't forget to deallocate struct members\n";
} }
}; };
@ -331,7 +331,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
} }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakNoVar checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakNoVar checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.check(); checkMemoryLeak.check();
} }
@ -355,7 +355,7 @@ private:
void returnValueNotUsedError(const Token* tok, const std::string &alloc); void returnValueNotUsedError(const Token* tok, const std::string &alloc);
void unsafeArgAllocError(const Token *tok, const std::string &funcName, const std::string &ptrType, const std::string &objType); void unsafeArgAllocError(const Token *tok, const std::string &funcName, const std::string &ptrType, const std::string &objType);
void getErrorMessages(ErrorLogger *e, const Settings *settings) const override { void getErrorMessages(ErrorLogger *e, const Settings *settings) const OVERRIDE {
CheckMemoryLeakNoVar c(nullptr, settings, e); CheckMemoryLeakNoVar c(nullptr, settings, e);
c.functionCallLeak(nullptr, "funcName", "funcName"); c.functionCallLeak(nullptr, "funcName", "funcName");
@ -367,7 +367,7 @@ private:
return "Memory leaks (address not taken)"; return "Memory leaks (address not taken)";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Not taking the address to allocated memory\n"; return "Not taking the address to allocated memory\n";
} }
}; };

View File

@ -55,14 +55,14 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger); CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger);
checkNullPointer.nullPointer(); checkNullPointer.nullPointer();
checkNullPointer.arithmetic(); checkNullPointer.arithmetic();
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger); CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger);
checkNullPointer.nullConstantDereference(); checkNullPointer.nullConstantDereference();
} }
@ -114,16 +114,16 @@ public:
}; };
/** @brief Parse current TU and extract file info */ /** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const OVERRIDE;
Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override; Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const OVERRIDE;
/** @brief Analyse all file infos for all TU */ /** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) OVERRIDE;
private: private:
/** Get error messages. Used by --errorlist */ /** Get error messages. Used by --errorlist */
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckNullPointer c(nullptr, settings, errorLogger); CheckNullPointer c(nullptr, settings, errorLogger);
c.nullPointerError(nullptr, "pointer", nullptr, false); c.nullPointerError(nullptr, "pointer", nullptr, false);
c.pointerArithmeticError(nullptr, nullptr, false); c.pointerArithmeticError(nullptr, nullptr, false);
@ -136,7 +136,7 @@ private:
} }
/** class info in WIKI format. Used by --doc */ /** class info in WIKI format. Used by --doc */
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Null pointers\n" return "Null pointers\n"
"- null pointer dereferencing\n" "- null pointer dereferencing\n"
"- undefined null pointer arithmetic\n"; "- undefined null pointer arithmetic\n";

View File

@ -54,7 +54,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckOther checkOther(tokenizer, settings, errorLogger); CheckOther checkOther(tokenizer, settings, errorLogger);
// Checks // Checks
@ -86,7 +86,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckOther checkOther(tokenizer, settings, errorLogger); CheckOther checkOther(tokenizer, settings, errorLogger);
// Checks // Checks
@ -273,7 +273,7 @@ private:
void shadowError(const Token *var, const Token *shadowed, bool shadowVar); void shadowError(const Token *var, const Token *shadowed, bool shadowVar);
void constArgumentError(const Token *tok, const Token *ftok, const ValueFlow::Value *value); void constArgumentError(const Token *tok, const Token *ftok, const ValueFlow::Value *value);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckOther c(nullptr, settings, errorLogger); CheckOther c(nullptr, settings, errorLogger);
ErrorPath errorPath; ErrorPath errorPath;
@ -346,7 +346,7 @@ private:
return "Other"; return "Other";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Other checks\n" return "Other checks\n"
// error // error

View File

@ -50,14 +50,14 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())
return; return;
CheckPostfixOperator checkPostfixOperator(tokenizer, settings, errorLogger); CheckPostfixOperator checkPostfixOperator(tokenizer, settings, errorLogger);
checkPostfixOperator.postfixOperator(); checkPostfixOperator.postfixOperator();
} }
void runSimplifiedChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) override { void runSimplifiedChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {
} }
/** Check postfix operators */ /** Check postfix operators */
@ -67,7 +67,7 @@ private:
/** Report Error */ /** Report Error */
void postfixOperatorError(const Token *tok); void postfixOperatorError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckPostfixOperator c(nullptr, settings, errorLogger); CheckPostfixOperator c(nullptr, settings, errorLogger);
c.postfixOperatorError(nullptr); c.postfixOperatorError(nullptr);
} }
@ -76,7 +76,7 @@ private:
return "Using postfix operators"; return "Using postfix operators";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Warn if using postfix operators ++ or -- rather than prefix operator\n"; return "Warn if using postfix operators ++ or -- rather than prefix operator\n";
} }
}; };

View File

@ -50,7 +50,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) override { void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) OVERRIDE {
CheckSizeof checkSizeof(tokenizer, settings, errorLogger); CheckSizeof checkSizeof(tokenizer, settings, errorLogger);
// Checks // Checks
@ -65,7 +65,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) override { void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) OVERRIDE {
} }
/** @brief %Check for 'sizeof sizeof ..' */ /** @brief %Check for 'sizeof sizeof ..' */
@ -107,7 +107,7 @@ private:
void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname); void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname);
void arithOperationsOnVoidPointerError(const Token* tok, const std::string &varname, const std::string &vartype); void arithOperationsOnVoidPointerError(const Token* tok, const std::string &varname, const std::string &vartype);
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const override { void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const OVERRIDE {
CheckSizeof c(nullptr, settings, errorLogger); CheckSizeof c(nullptr, settings, errorLogger);
c.sizeofForArrayParameterError(nullptr); c.sizeofForArrayParameterError(nullptr);
@ -128,7 +128,7 @@ private:
return "Sizeof"; return "Sizeof";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "sizeof() usage checks\n" return "sizeof() usage checks\n"
"- sizeof for array given as function argument\n" "- sizeof for array given as function argument\n"
"- sizeof for numeric given as function argument\n" "- sizeof for numeric given as function argument\n"

View File

@ -54,7 +54,7 @@ public:
} }
/** run checks, the token list is not simplified */ /** run checks, the token list is not simplified */
virtual void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { virtual void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (!tokenizer->isCPP()) { if (!tokenizer->isCPP()) {
return; return;
} }
@ -65,7 +65,7 @@ public:
} }
/** Simplified checks. The token list is simplified. */ /** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) override { void runSimplifiedChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) OVERRIDE {
if (!tokenizer->isCPP()) { if (!tokenizer->isCPP()) {
return; return;
} }
@ -237,7 +237,7 @@ private:
bool compareIteratorAgainstDifferentContainer(const Token* tok, const Token* containerToken, const unsigned int iteratorId, const std::map<unsigned int, const Token*>& iteratorScopeBeginInfo); bool compareIteratorAgainstDifferentContainer(const Token* tok, const Token* containerToken, const unsigned int iteratorId, const std::map<unsigned int, const Token*>& iteratorScopeBeginInfo);
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const override { void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const OVERRIDE {
CheckStl c(nullptr, settings, errorLogger); CheckStl c(nullptr, settings, errorLogger);
c.outOfBoundsError(nullptr, nullptr, nullptr); c.outOfBoundsError(nullptr, nullptr, nullptr);
c.invalidIteratorError(nullptr, "iterator"); c.invalidIteratorError(nullptr, "iterator");
@ -282,7 +282,7 @@ private:
return "STL usage"; return "STL usage";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check for invalid usage of STL:\n" return "Check for invalid usage of STL:\n"
"- out of bounds errors\n" "- out of bounds errors\n"
"- misuse of iterators when iterating through a container\n" "- misuse of iterators when iterating through a container\n"

View File

@ -50,7 +50,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckString checkString(tokenizer, settings, errorLogger); CheckString checkString(tokenizer, settings, errorLogger);
// Checks // Checks
@ -61,7 +61,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckString checkString(tokenizer, settings, errorLogger); CheckString checkString(tokenizer, settings, errorLogger);
// Checks // Checks
@ -103,7 +103,7 @@ private:
void suspiciousStringCompareError_char(const Token* tok, const std::string& var); void suspiciousStringCompareError_char(const Token* tok, const std::string& var);
void overlappingStrcmpError(const Token* eq0, const Token *ne0); void overlappingStrcmpError(const Token* eq0, const Token *ne0);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckString c(nullptr, settings, errorLogger); CheckString c(nullptr, settings, errorLogger);
c.stringLiteralWriteError(nullptr, nullptr); c.stringLiteralWriteError(nullptr, nullptr);
@ -123,7 +123,7 @@ private:
return "String"; return "String";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Detect misusage of C-style strings:\n" return "Detect misusage of C-style strings:\n"
"- overlapping buffers passed to sprintf as source and destination\n" "- overlapping buffers passed to sprintf as source and destination\n"
"- incorrect length arguments for 'substr' and 'strncmp'\n" "- incorrect length arguments for 'substr' and 'strncmp'\n"

View File

@ -49,7 +49,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
// These are not "simplified" because casts can't be ignored // These are not "simplified" because casts can't be ignored
CheckType checkType(tokenizer, settings, errorLogger); CheckType checkType(tokenizer, settings, errorLogger);
checkType.checkTooBigBitwiseShift(); checkType.checkTooBigBitwiseShift();
@ -60,7 +60,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer; (void)tokenizer;
(void)settings; (void)settings;
(void)errorLogger; (void)errorLogger;
@ -91,7 +91,7 @@ private:
void longCastReturnError(const Token *tok); void longCastReturnError(const Token *tok);
void floatToIntegerOverflowError(const Token *tok, const ValueFlow::Value &value); void floatToIntegerOverflowError(const Token *tok, const ValueFlow::Value &value);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckType c(nullptr, settings, errorLogger); CheckType c(nullptr, settings, errorLogger);
c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64)); c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64));
c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31)); c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31));
@ -109,7 +109,7 @@ private:
return "Type"; return "Type";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Type checks\n" return "Type checks\n"
"- bitwise shift by too many bits (only enabled when --platform is used)\n" "- bitwise shift by too many bits (only enabled when --platform is used)\n"
"- signed integer overflow (only enabled when --platform is used)\n" "- signed integer overflow (only enabled when --platform is used)\n"

View File

@ -61,7 +61,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckUninitVar checkUninitVar(tokenizer, settings, errorLogger); CheckUninitVar checkUninitVar(tokenizer, settings, errorLogger);
checkUninitVar.check(); checkUninitVar.check();
checkUninitVar.deadPointer(); checkUninitVar.deadPointer();
@ -100,12 +100,12 @@ public:
}; };
/** @brief Parse current TU and extract file info */ /** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const OVERRIDE;
Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override; Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const OVERRIDE;
/** @brief Analyse all file infos for all TU */ /** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) OVERRIDE;
void uninitstringError(const Token *tok, const std::string &varname, bool strncpy_); void uninitstringError(const Token *tok, const std::string &varname, bool strncpy_);
void uninitdataError(const Token *tok, const std::string &varname); void uninitdataError(const Token *tok, const std::string &varname);
@ -122,7 +122,7 @@ private:
Check::FileInfo *getFileInfo() const; Check::FileInfo *getFileInfo() const;
bool isUnsafeFunction(const Scope *scope, int argnr, const Token **tok) const; bool isUnsafeFunction(const Scope *scope, int argnr, const Token **tok) const;
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckUninitVar c(nullptr, settings, errorLogger); CheckUninitVar c(nullptr, settings, errorLogger);
// error // error
@ -137,7 +137,7 @@ private:
return "Uninitialized variables"; return "Uninitialized variables";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Uninitialized variables\n" return "Uninitialized variables\n"
"- using uninitialized local variables\n" "- using uninitialized local variables\n"
"- using allocated data before it has been initialized\n" "- using allocated data before it has been initialized\n"

View File

@ -64,10 +64,10 @@ public:
bool check(ErrorLogger * const errorLogger, const Settings& settings); bool check(ErrorLogger * const errorLogger, const Settings& settings);
/** @brief Parse current TU and extract file info */ /** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const OVERRIDE;
/** @brief Analyse all file infos for all TU */ /** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) OVERRIDE;
static CheckUnusedFunctions instance; static CheckUnusedFunctions instance;
@ -78,7 +78,7 @@ public:
private: private:
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckUnusedFunctions c(nullptr, settings, errorLogger); CheckUnusedFunctions c(nullptr, settings, errorLogger);
c.unusedFunctionError(errorLogger, emptyString, 0, "funcName"); c.unusedFunctionError(errorLogger, emptyString, 0, "funcName");
} }
@ -93,14 +93,14 @@ private:
/** /**
* Dummy implementation, just to provide error for --errorlist * Dummy implementation, just to provide error for --errorlist
*/ */
void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) override { void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) OVERRIDE {
} }
static std::string myName() { static std::string myName() {
return "Unused functions"; return "Unused functions";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check for functions that are never called\n"; return "Check for functions that are never called\n";
} }

View File

@ -53,7 +53,7 @@ public:
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckUnusedVar checkUnusedVar(tokenizer, settings, errorLogger); CheckUnusedVar checkUnusedVar(tokenizer, settings, errorLogger);
// Coding style checks // Coding style checks
@ -62,7 +62,7 @@ public:
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer; (void)tokenizer;
(void)settings; (void)settings;
(void)errorLogger; (void)errorLogger;
@ -86,7 +86,7 @@ private:
void unreadVariableError(const Token *tok, const std::string &varname, bool modified); void unreadVariableError(const Token *tok, const std::string &varname, bool modified);
void unassignedVariableError(const Token *tok, const std::string &varname); void unassignedVariableError(const Token *tok, const std::string &varname);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckUnusedVar c(nullptr, settings, errorLogger); CheckUnusedVar c(nullptr, settings, errorLogger);
// style/warning // style/warning
@ -101,7 +101,7 @@ private:
return "UnusedVar"; return "UnusedVar";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "UnusedVar checks\n" return "UnusedVar checks\n"
// style // style

View File

@ -48,7 +48,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override { virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckVaarg check(tokenizer, settings, errorLogger); CheckVaarg check(tokenizer, settings, errorLogger);
check.va_start_argument(); check.va_start_argument();
check.va_list_usage(); check.va_list_usage();
@ -64,7 +64,7 @@ private:
void va_list_usedBeforeStartedError(const Token *tok, const std::string& varname); void va_list_usedBeforeStartedError(const Token *tok, const std::string& varname);
void va_start_subsequentCallsError(const Token *tok, const std::string& varname); void va_start_subsequentCallsError(const Token *tok, const std::string& varname);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckVaarg c(nullptr, settings, errorLogger); CheckVaarg c(nullptr, settings, errorLogger);
c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2"); c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2");
c.referenceAs_va_start_error(nullptr, "arg1"); c.referenceAs_va_start_error(nullptr, "arg1");
@ -77,7 +77,7 @@ private:
return "Vaarg"; return "Vaarg";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Check for misusage of variable argument lists:\n" return "Check for misusage of variable argument lists:\n"
"- Wrong parameter passed to va_start()\n" "- Wrong parameter passed to va_start()\n"
"- Reference passed to va_start()\n" "- Reference passed to va_start()\n"

View File

@ -19,6 +19,13 @@
# include <crtdbg.h> # include <crtdbg.h>
#endif #endif
// C++11 override
#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC >= 5))
# define OVERRIDE override
#else
# define OVERRIDE
#endif
#include <string> #include <string>
static const std::string emptyString; static const std::string emptyString;

View File

@ -189,24 +189,24 @@ private:
* "[filepath:line number] Message", e.g. * "[filepath:line number] Message", e.g.
* "[main.cpp:4] Uninitialized member variable" * "[main.cpp:4] Uninitialized member variable"
*/ */
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) override; virtual void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
/** /**
* @brief Information about progress is directed here. * @brief Information about progress is directed here.
* *
* @param outmsg Message to show, e.g. "Checking main.cpp..." * @param outmsg Message to show, e.g. "Checking main.cpp..."
*/ */
virtual void reportOut(const std::string &outmsg) override; virtual void reportOut(const std::string &outmsg) OVERRIDE;
std::list<std::string> mErrorList; std::list<std::string> mErrorList;
Settings mSettings; Settings mSettings;
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; void reportProgress(const std::string &filename, const char stage[], const std::size_t value) OVERRIDE;
/** /**
* Output information messages. * Output information messages.
*/ */
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) override; virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
ErrorLogger &mErrorLogger; ErrorLogger &mErrorLogger;

View File

@ -35,7 +35,7 @@ namespace CTU {
public: public:
enum InvalidValueType { null, uninit }; enum InvalidValueType { null, uninit };
std::string toString() const override; std::string toString() const OVERRIDE;
struct Location { struct Location {
Location() = default; Location() = default;

View File

@ -61,7 +61,7 @@ public:
} }
void ShowResults(SHOWTIME_MODES mode) const; void ShowResults(SHOWTIME_MODES mode) const;
virtual void AddResults(const std::string& str, std::clock_t clocks) override; virtual void AddResults(const std::string& str, std::clock_t clocks) OVERRIDE;
private: private:
std::map<std::string, struct TimerResultsData> mResults; std::map<std::string, struct TimerResultsData> mResults;

View File

@ -82,8 +82,8 @@ protected:
void processOptions(const options& args); void processOptions(const options& args);
public: public:
virtual void reportOut(const std::string &outmsg) override; virtual void reportOut(const std::string &outmsg) OVERRIDE;
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) override; virtual void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
void run(const std::string &str); void run(const std::string &str);
const std::string classname; const std::string classname;

View File

@ -50,10 +50,10 @@ public:
SimpleSuppressor(Settings &settings, ErrorLogger *next) SimpleSuppressor(Settings &settings, ErrorLogger *next)
: _settings(settings), _next(next) { : _settings(settings), _next(next) {
} }
virtual void reportOut(const std::string &outmsg) override { virtual void reportOut(const std::string &outmsg) OVERRIDE {
_next->reportOut(outmsg); _next->reportOut(outmsg);
} }
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) override { virtual void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE {
if (!msg._callStack.empty() && !_settings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage())) if (!msg._callStack.empty() && !_settings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
_next->reportErr(msg); _next->reportErr(msg);
} }