refactoring - added 'getErrorMessages' to all check classes
This commit is contained in:
parent
0a71771c6a
commit
e017d5a079
|
@ -61,8 +61,7 @@ public:
|
||||||
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) = 0;
|
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) = 0;
|
||||||
|
|
||||||
/** get error messages */
|
/** get error messages */
|
||||||
virtual void getErrorMessages()
|
virtual void getErrorMessages() = 0;
|
||||||
{ }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Tokenizer * const _tokenizer;
|
const Tokenizer * const _tokenizer;
|
||||||
|
|
|
@ -54,6 +54,11 @@ private:
|
||||||
bool error_av(const Token* left, const Token* right);
|
bool error_av(const Token* left, const Token* right);
|
||||||
bool is_auto_var(const Token* t);
|
bool is_auto_var(const Token* t);
|
||||||
void addVD(const Token* t);
|
void addVD(const Token* t);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -72,6 +72,14 @@ private:
|
||||||
void bufferOverrun(const Token *tok);
|
void bufferOverrun(const Token *tok);
|
||||||
void strncatUsage(const Token *tok);
|
void strncatUsage(const Token *tok);
|
||||||
void outOfBounds(const Token *tok, const std::string &what);
|
void outOfBounds(const Token *tok, const std::string &what);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
arrayIndexOutOfBounds(0);
|
||||||
|
bufferOverrun(0);
|
||||||
|
strncatUsage(0);
|
||||||
|
outOfBounds(0, "index");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -107,6 +107,17 @@ private:
|
||||||
void operatorEqError(const Token *tok);
|
void operatorEqError(const Token *tok);
|
||||||
void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived);
|
void virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
noConstructorError(0, "classname");
|
||||||
|
uninitVarError(0, "classname", "varname");
|
||||||
|
unusedPrivateFunctionError(0, "classname", "funcname");
|
||||||
|
memsetClassError(0, "memfunc");
|
||||||
|
memsetStructError(0, "memfunc", "classname");
|
||||||
|
operatorEqError(0);
|
||||||
|
virtualDestructorError(0, "Base", "Derived");
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,6 +52,12 @@ private:
|
||||||
void dangerousFunctiongets(const Token *tok);
|
void dangerousFunctiongets(const Token *tok);
|
||||||
void dangerousFunctionscanf(const Token *tok);
|
void dangerousFunctionscanf(const Token *tok);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
dangerousFunctionmktemp(0);
|
||||||
|
dangerousFunctiongets(0);
|
||||||
|
dangerousFunctionscanf(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,6 +133,21 @@ private:
|
||||||
void mismatchSizeError(const Token *tok, const std::string &sz);
|
void mismatchSizeError(const Token *tok, const std::string &sz);
|
||||||
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname);
|
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname);
|
||||||
|
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
memleakError(0, "varname");
|
||||||
|
memleakallError(0, "varname");
|
||||||
|
resourceLeakError(0, "varname");
|
||||||
|
deallocDeallocError(0, "varname");
|
||||||
|
deallocuseError(0, "varname");
|
||||||
|
mismatchSizeError(0, "sz");
|
||||||
|
|
||||||
|
std::list<const Token *> callstack;
|
||||||
|
mismatchAllocDealloc(callstack, "varname");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Experimental functionality..
|
// Experimental functionality..
|
||||||
protected:
|
protected:
|
||||||
Token *functionParameterCode(const Token *ftok, int parameter);
|
Token *functionParameterCode(const Token *ftok, int parameter);
|
||||||
|
|
|
@ -132,6 +132,27 @@ private:
|
||||||
void strPlusChar(const Token *tok);
|
void strPlusChar(const Token *tok);
|
||||||
void returnLocalVariable(const Token *tok);
|
void returnLocalVariable(const Token *tok);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
cstyleCastError(0);
|
||||||
|
redundantIfDelete0Error(0);
|
||||||
|
redundantIfRemoveError(0);
|
||||||
|
dangerousUsageStrtolError(0);
|
||||||
|
ifNoActionError(0);
|
||||||
|
sprintfOverlappingDataError(0, "varname");
|
||||||
|
udivError(0);
|
||||||
|
udivWarning(0);
|
||||||
|
unusedStructMemberError(0, "structname", "varname");
|
||||||
|
passedByValueError(0, "parname");
|
||||||
|
constStatementError(0, "type");
|
||||||
|
charArrayIndexError(0);
|
||||||
|
charBitOpError(0);
|
||||||
|
variableScopeError(0, "varname");
|
||||||
|
conditionAlwaysTrueFalse(0, "true/false");
|
||||||
|
strPlusChar(0);
|
||||||
|
returnLocalVariable(0);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -52,6 +52,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void unvalidatedInput(const Token *tok);
|
void unvalidatedInput(const Token *tok);
|
||||||
|
|
||||||
|
void getErrorMessages()
|
||||||
|
{
|
||||||
|
unvalidatedInput(0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue