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 */
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.pointerassignment();
}
/** @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)settings;
(void)errorLogger;
@ -74,7 +74,7 @@ private:
void returnIntegerError(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);
c.assignmentAddressToIntegerError(nullptr);
c.assignmentIntegerToAddressError(nullptr);
@ -86,7 +86,7 @@ private:
return "64-bit portability";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check if there is 64-bit portability issues:\n"
"- assign address to/from int/long\n"
"- casting address from/to integer when returning from function\n";

View File

@ -49,7 +49,7 @@ public:
: 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);
check.assertWithSideEffects();
}
@ -64,7 +64,7 @@ private:
void sideEffectInAssertError(const Token *tok, const std::string& functionName);
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);
c.sideEffectInAssertError(nullptr, "function");
c.assignmentInAssertError(nullptr, "var");
@ -74,7 +74,7 @@ private:
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";
}
};

View File

@ -49,14 +49,14 @@ public:
}
/** @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.assignFunctionArg();
checkAutoVariables.returnReference();
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.autoVariables();
}
@ -98,7 +98,7 @@ private:
void errorUselessAssignmentArg(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);
c.errorAutoVariableAssignment(nullptr, false);
c.errorReturnAddressToAutoVariable(nullptr);
@ -119,7 +119,7 @@ private:
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"
"Check:\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 */
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);
// Checks
@ -62,7 +62,7 @@ public:
}
/** @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);
// Checks
@ -118,7 +118,7 @@ private:
void pointerArithBoolError(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);
c.assignBoolToPointerError(nullptr);
@ -138,7 +138,7 @@ private:
return "Boolean";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Boolean type checks\n"
"- using increment on boolean\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. */
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())
return;
@ -64,7 +64,7 @@ public:
private:
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);
c.boostForeachError(nullptr);
}
@ -73,7 +73,7 @@ private:
return "Boost usage";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check for invalid usage of Boost:\n"
"- container modification during BOOST_FOREACH\n";
}

View File

@ -73,7 +73,7 @@ public:
: 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.checkGlobalAndLocalVariable();
if (tokenizer && tokenizer->isMaxTime())
@ -85,7 +85,7 @@ public:
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.bufferOverrun();
checkBufferOverrun.checkStringArgument();
@ -222,7 +222,7 @@ public:
/* data for multifile checking */
class MyFileInfo : public Check::FileInfo {
public:
std::string toString() const override;
std::string toString() const OVERRIDE;
struct ArrayUsage {
MathLib::bigint index;
@ -238,12 +238,12 @@ public:
};
/** @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 */
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.
@ -275,7 +275,7 @@ private:
void valueFlowCheckArrayIndex(const Token * const tok, const ArrayInfo &arrayInfo);
public:
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override {
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckBufferOverrun c(nullptr, settings, errorLogger);
const std::vector<MathLib::bigint> indexes(2, 1);
c.arrayIndexOutOfBoundsError(nullptr, ArrayInfo(0, "array", 1, 2), indexes);
@ -301,7 +301,7 @@ private:
return "Bounds checking";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Out of bounds checking:\n"
"- Array index out of bounds detection by value flow analysis\n"
"- Dangerous usage of strncat()\n"

View File

@ -53,7 +53,7 @@ public:
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
/** @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())
return;
@ -65,7 +65,7 @@ public:
}
/** @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())
return;
@ -198,7 +198,7 @@ private:
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 getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override {
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckClass c(nullptr, settings, errorLogger);
c.noConstructorError(nullptr, "classname", false);
c.noExplicitConstructorError(nullptr, "classname", false);
@ -240,7 +240,7 @@ private:
return "Class";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check the code for each class.\n"
"- Missing constructors and copy constructors\n"
//"- Missing allocation of memory in copy constructor\n"

View File

@ -51,7 +51,7 @@ public:
: 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.multiCondition();
checkCondition.clarifyCondition(); // not simplified because ifAssign
@ -64,7 +64,7 @@ public:
}
/** @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.assignIf();
checkCondition.checkBadBitmaskCheck();
@ -156,7 +156,7 @@ private:
void invalidTestForOverflow(const Token* tok, bool result);
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);
ErrorPath errorPath;
@ -183,7 +183,7 @@ private:
return "Condition";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Match conditions with assignments and other conditions:\n"
"- Mismatching assignment and 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 */
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())
return;
@ -137,7 +137,7 @@ private:
}
/** 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);
c.destructorsError(nullptr, "Class");
c.deallocThrowError(nullptr, "p");
@ -153,7 +153,7 @@ private:
}
/** wiki formatted description of the class (for --doc) */
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Checking exception safety\n"
"- Throwing exceptions in destructors\n"
"- Throwing exception during invalid state\n"

View File

@ -58,7 +58,7 @@ public:
}
/** @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);
// Checks
@ -69,7 +69,7 @@ public:
}
/** @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.checkProhibitedFunctions();
@ -118,7 +118,7 @@ private:
void memsetFloatError(const Token *tok, const std::string &var_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);
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";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check function usage:\n"
"- return value of certain functions not used\n"
"- invalid input values for functions\n"

View File

@ -44,7 +44,7 @@ public:
}
/** 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))
return;
@ -94,7 +94,7 @@ private:
void extraWhitespaceError(const Token *tok, const std::string &pattern, const std::string &funcname);
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);
c.multiComparePatternError(nullptr, ";|%type%", "Match");
c.simplePatternError(nullptr, "class {", "Match");
@ -111,7 +111,7 @@ private:
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
// checks there are. These checks are not intended for users.
return "";

View File

@ -50,14 +50,14 @@ public:
}
/** @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.checkWrongPrintfScanfArguments();
}
/** @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.checkCoutCerrMisusage();
@ -139,7 +139,7 @@ private:
static void argumentType(std::ostream & os, 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);
c.coutCerrMisusageError(nullptr, "cout");
@ -170,7 +170,7 @@ private:
return "IO using format string";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check format string input/output operations.\n"
"- Bad usage of the function 'sprintf' (overlapping data)\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 */
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.check();
}
@ -147,7 +147,7 @@ private:
/** message: user configuration is needed to complete analysis */
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);
c.deallocReturnError(nullptr, "p");
c.configurationInfo(nullptr, "f"); // user configuration is needed to complete analysis
@ -158,7 +158,7 @@ private:
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";
}
};

View File

@ -184,7 +184,7 @@ public:
}
/** @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);
checkMemoryLeak.checkReallocUsage();
}
@ -199,7 +199,7 @@ public:
private:
/** 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);
c.memleakError(nullptr, "varname");
@ -225,7 +225,7 @@ private:
* Get class information (--doc)
* @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";
}
};
@ -245,7 +245,7 @@ public:
: 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())
return;
@ -264,7 +264,7 @@ private:
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);
c.publicAllocationError(nullptr, "varname");
c.unsafeClassError(nullptr, "class", "class::varname");
@ -274,7 +274,7 @@ private:
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";
}
};
@ -292,7 +292,7 @@ public:
: 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);
checkMemoryLeak.check();
}
@ -306,14 +306,14 @@ private:
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() {
return "Memory leaks (struct members)";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Don't forget to deallocate struct members\n";
}
};
@ -331,7 +331,7 @@ public:
: 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);
checkMemoryLeak.check();
}
@ -355,7 +355,7 @@ private:
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 getErrorMessages(ErrorLogger *e, const Settings *settings) const override {
void getErrorMessages(ErrorLogger *e, const Settings *settings) const OVERRIDE {
CheckMemoryLeakNoVar c(nullptr, settings, e);
c.functionCallLeak(nullptr, "funcName", "funcName");
@ -367,7 +367,7 @@ private:
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";
}
};

View File

@ -55,14 +55,14 @@ public:
}
/** @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.nullPointer();
checkNullPointer.arithmetic();
}
/** @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.nullConstantDereference();
}
@ -114,16 +114,16 @@ public:
};
/** @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 */
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:
/** 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);
c.nullPointerError(nullptr, "pointer", nullptr, false);
c.pointerArithmeticError(nullptr, nullptr, false);
@ -136,7 +136,7 @@ private:
}
/** class info in WIKI format. Used by --doc */
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Null pointers\n"
"- null pointer dereferencing\n"
"- undefined null pointer arithmetic\n";

View File

@ -54,7 +54,7 @@ public:
}
/** @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);
// Checks
@ -86,7 +86,7 @@ public:
}
/** @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);
// Checks
@ -273,7 +273,7 @@ private:
void shadowError(const Token *var, const Token *shadowed, bool shadowVar);
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);
ErrorPath errorPath;
@ -346,7 +346,7 @@ private:
return "Other";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Other checks\n"
// error

View File

@ -50,14 +50,14 @@ public:
: 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())
return;
CheckPostfixOperator checkPostfixOperator(tokenizer, settings, errorLogger);
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 */
@ -67,7 +67,7 @@ private:
/** Report Error */
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);
c.postfixOperatorError(nullptr);
}
@ -76,7 +76,7 @@ private:
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";
}
};

View File

@ -50,7 +50,7 @@ public:
}
/** @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);
// Checks
@ -65,7 +65,7 @@ public:
}
/** @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 ..' */
@ -107,7 +107,7 @@ private:
void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname);
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);
c.sizeofForArrayParameterError(nullptr);
@ -128,7 +128,7 @@ private:
return "Sizeof";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "sizeof() usage checks\n"
"- sizeof for array 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 */
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()) {
return;
}
@ -65,7 +65,7 @@ public:
}
/** 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()) {
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);
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const override {
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const OVERRIDE {
CheckStl c(nullptr, settings, errorLogger);
c.outOfBoundsError(nullptr, nullptr, nullptr);
c.invalidIteratorError(nullptr, "iterator");
@ -282,7 +282,7 @@ private:
return "STL usage";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check for invalid usage of STL:\n"
"- out of bounds errors\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 */
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);
// Checks
@ -61,7 +61,7 @@ public:
}
/** @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);
// Checks
@ -103,7 +103,7 @@ private:
void suspiciousStringCompareError_char(const Token* tok, const std::string& var);
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);
c.stringLiteralWriteError(nullptr, nullptr);
@ -123,7 +123,7 @@ private:
return "String";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Detect misusage of C-style strings:\n"
"- overlapping buffers passed to sprintf as source and destination\n"
"- incorrect length arguments for 'substr' and 'strncmp'\n"

View File

@ -49,7 +49,7 @@ public:
}
/** @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
CheckType checkType(tokenizer, settings, errorLogger);
checkType.checkTooBigBitwiseShift();
@ -60,7 +60,7 @@ public:
}
/** @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)settings;
(void)errorLogger;
@ -91,7 +91,7 @@ private:
void longCastReturnError(const Token *tok);
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);
c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64));
c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31));
@ -109,7 +109,7 @@ private:
return "Type";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Type checks\n"
"- bitwise shift by too many bits (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 */
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.check();
checkUninitVar.deadPointer();
@ -100,12 +100,12 @@ public:
};
/** @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 */
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 uninitdataError(const Token *tok, const std::string &varname);
@ -122,7 +122,7 @@ private:
Check::FileInfo *getFileInfo() 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);
// error
@ -137,7 +137,7 @@ private:
return "Uninitialized variables";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Uninitialized variables\n"
"- using uninitialized local variables\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);
/** @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 */
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;
@ -78,7 +78,7 @@ public:
private:
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override {
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckUnusedFunctions c(nullptr, settings, errorLogger);
c.unusedFunctionError(errorLogger, emptyString, 0, "funcName");
}
@ -93,14 +93,14 @@ private:
/**
* 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() {
return "Unused functions";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check for functions that are never called\n";
}

View File

@ -53,7 +53,7 @@ public:
}
/** @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);
// Coding style checks
@ -62,7 +62,7 @@ public:
}
/** @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)settings;
(void)errorLogger;
@ -86,7 +86,7 @@ private:
void unreadVariableError(const Token *tok, const std::string &varname, bool modified);
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);
// style/warning
@ -101,7 +101,7 @@ private:
return "UnusedVar";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "UnusedVar checks\n"
// style

View File

@ -48,7 +48,7 @@ public:
: 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);
check.va_start_argument();
check.va_list_usage();
@ -64,7 +64,7 @@ private:
void va_list_usedBeforeStartedError(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);
c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2");
c.referenceAs_va_start_error(nullptr, "arg1");
@ -77,7 +77,7 @@ private:
return "Vaarg";
}
std::string classInfo() const override {
std::string classInfo() const OVERRIDE {
return "Check for misusage of variable argument lists:\n"
"- Wrong parameter passed to va_start()\n"
"- Reference passed to va_start()\n"

View File

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

View File

@ -189,24 +189,24 @@ private:
* "[filepath:line number] Message", e.g.
* "[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.
*
* @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;
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.
*/
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) override;
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
ErrorLogger &mErrorLogger;

View File

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

View File

@ -61,7 +61,7 @@ public:
}
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:
std::map<std::string, struct TimerResultsData> mResults;

View File

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

View File

@ -50,10 +50,10 @@ public:
SimpleSuppressor(Settings &settings, ErrorLogger *next)
: _settings(settings), _next(next) {
}
virtual void reportOut(const std::string &outmsg) override {
virtual void reportOut(const std::string &outmsg) OVERRIDE {
_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()))
_next->reportErr(msg);
}