50 #define WRONG_DATA(COND, TOK) ((COND) && wrongData((TOK), #COND))
62 explicit Check(
const std::string &aname);
67 : mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger), mName(std::move(aname)) {}
72 instances().remove(
this);
79 static std::list<Check *> &instances();
88 const std::string&
name()
const {
100 static void writeToErrorList(
const ErrorMessage &errmsg);
108 return std::string();
131 static std::string getMessageId(
const ValueFlow::Value &value,
const char id[]);
144 const std::list<const Token *> callstack(1, tok);
145 reportError(callstack, severity,
id, msg, cwe, certainty);
149 void reportError(
const std::list<const Token *> &callstack,
Severity severity,
const std::string &
id,
const std::string &msg) {
154 void reportError(
const std::list<const Token *> &callstack,
Severity severity,
const std::string &
id,
const std::string &msg,
const CWE &cwe,
Certainty certainty);
156 void reportError(
const ErrorPath &errorPath,
Severity severity,
const char id[],
const std::string &msg,
const CWE &cwe,
Certainty certainty);
167 bool wrongData(
const Token *tok,
const char *str);
Base class used for whole-program analysis.
virtual ~FileInfo()=default
virtual std::string toString() const
Interface class that cppcheck uses to communicate with the checks.
Check(std::string aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
virtual bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list< FileInfo * > &fileInfo, const Settings &, ErrorLogger &)
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg)
report an error
virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const =0
get error messages
Check(const Check &)=delete
virtual void runChecks(const Tokenizer &, ErrorLogger *)=0
run checks, the token list is not simplified
Check & operator=(const Check &)=delete
virtual FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
void reportError(const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg)
report an error
virtual FileInfo * getFileInfo(const Tokenizer &, const Settings &) const
virtual std::string classInfo() const =0
get information about this class, used to generate documentation
const std::string & name() const
class name, used to generate documentation
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty)
report an error
This is an interface, which the class responsible of error logging should implement.
Wrapper for error messages, provided by reportErr()
This is just a container for general settings so that we don't need to pass individual values to func...
The token list that the TokenList generates is a linked-list of this class.
The main purpose is to tokenize the source code.
Severity
enum class for severity.
std::list< ErrorPathItem > ErrorPath
Whole program analysis (ctu=Cross Translation Unit)
static constexpr char CWE[]