Cppcheck
Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
CheckInternal Class Reference

Check Internal cppcheck API usage More...

#include <checkinternal.h>

Inheritance diagram for CheckInternal:
Check

Public Member Functions

 CheckInternal ()
 This constructor is used when registering the CheckClass. More...
 
- Public Member Functions inherited from Check
 Check (const std::string &aname)
 This constructor is used when registering the CheckClass. More...
 
virtual ~Check ()
 
 Check (const Check &)=delete
 
Checkoperator= (const Check &)=delete
 
const std::string & name () const
 class name, used to generate documentation More...
 
virtual FileInfogetFileInfo (const Tokenizer &, const Settings &) const
 
virtual FileInfoloadFileInfoFromXml (const tinyxml2::XMLElement *xmlElement) const
 
virtual bool analyseWholeProgram (const CTU::FileInfo *ctu, const std::list< FileInfo * > &fileInfo, const Settings &, ErrorLogger &)
 

Private Member Functions

 CheckInternal (const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
 This constructor is used when running checks. More...
 
void runChecks (const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
 run checks, the token list is not simplified More...
 
void checkTokenMatchPatterns ()
 Check if a simple pattern is used inside Token::Match or Token::findmatch More...
 
void checkTokenSimpleMatchPatterns ()
 Check if a complex pattern is used inside Token::simpleMatch or Token::findsimplematch More...
 
void checkMissingPercentCharacter ()
 Check for missing % end character in Token::Match pattern More...
 
void checkUnknownPattern ()
 Check for unknown (invalid) complex patterns like "%typ%" More...
 
void checkRedundantNextPrevious ()
 Check for inefficient usage of Token::next(), Token::previous() and Token::tokAt() More...
 
void checkExtraWhitespace ()
 Check if there is whitespace at the beginning or at the end of a pattern More...
 
void checkRedundantTokCheck ()
 Check if there is a redundant check for none-nullness of parameter before Match functions, such as (tok && Token::Match(tok, "foo")) More...
 
void multiComparePatternError (const Token *tok, const std::string &pattern, const std::string &funcname)
 
void simplePatternError (const Token *tok, const std::string &pattern, const std::string &funcname)
 
void complexPatternError (const Token *tok, const std::string &pattern, const std::string &funcname)
 
void missingPercentCharacterError (const Token *tok, const std::string &pattern, const std::string &funcname)
 
void unknownPatternError (const Token *tok, const std::string &pattern)
 
void redundantNextPreviousError (const Token *tok, const std::string &func1, const std::string &func2)
 
void orInComplexPattern (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 getErrorMessages (ErrorLogger *errorLogger, const Settings *settings) const override
 get error messages More...
 
std::string classInfo () const override
 get information about this class, used to generate documentation More...
 

Static Private Member Functions

static std::string myName ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Check
static std::list< Check * > & instances ()
 List of registered check classes. More...
 
static void writeToErrorList (const ErrorMessage &errmsg)
 Write given error to stdout in xml format. More...
 
- Protected Member Functions inherited from Check
 Check (std::string aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
 This constructor is used when running checks. More...
 
void reportError (const Token *tok, const Severity severity, const std::string &id, const std::string &msg)
 report an error More...
 
void reportError (const Token *tok, const Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty)
 report an error More...
 
void reportError (const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg)
 report an error More...
 
void reportError (const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty)
 report an error More...
 
void reportError (const ErrorPath &errorPath, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
 
void logChecker (const char id[])
 log checker More...
 
ErrorPath getErrorPath (const Token *errtok, const ValueFlow::Value *value, std::string bug) const
 
bool wrongData (const Token *tok, const char *str)
 Use WRONG_DATA in checkers when you check for wrong data. More...
 
- Static Protected Member Functions inherited from Check
static std::string getMessageId (const ValueFlow::Value &value, const char id[])
 
- Protected Attributes inherited from Check
const Tokenizer *const mTokenizer {}
 
const Settings *const mSettings {}
 
ErrorLogger *const mErrorLogger {}
 

Detailed Description

Check Internal cppcheck API usage

Definition at line 41 of file checkinternal.h.

Constructor & Destructor Documentation

◆ CheckInternal() [1/2]

CheckInternal::CheckInternal ( )
inline

This constructor is used when registering the CheckClass.

Definition at line 44 of file checkinternal.h.

◆ CheckInternal() [2/2]

CheckInternal::CheckInternal ( const Tokenizer tokenizer,
const Settings settings,
ErrorLogger errorLogger 
)
inlineprivate

This constructor is used when running checks.

Definition at line 48 of file checkinternal.h.

Member Function Documentation

◆ checkExtraWhitespace()

void CheckInternal::checkExtraWhitespace ( )
private

Check if there is whitespace at the beginning or at the end of a pattern

Referenced by runChecks().

◆ checkMissingPercentCharacter()

void CheckInternal::checkMissingPercentCharacter ( )
private

Check for missing % end character in Token::Match pattern

Referenced by runChecks().

◆ checkRedundantNextPrevious()

void CheckInternal::checkRedundantNextPrevious ( )
private

Check for inefficient usage of Token::next(), Token::previous() and Token::tokAt()

Referenced by runChecks().

◆ checkRedundantTokCheck()

void CheckInternal::checkRedundantTokCheck ( )
private

Check if there is a redundant check for none-nullness of parameter before Match functions, such as (tok && Token::Match(tok, "foo"))

Referenced by runChecks().

◆ checkRedundantTokCheckError()

void CheckInternal::checkRedundantTokCheckError ( const Token tok)
private

Referenced by getErrorMessages().

◆ checkTokenMatchPatterns()

void CheckInternal::checkTokenMatchPatterns ( )
private

Check if a simple pattern is used inside Token::Match or Token::findmatch

Referenced by runChecks().

◆ checkTokenSimpleMatchPatterns()

void CheckInternal::checkTokenSimpleMatchPatterns ( )
private

Check if a complex pattern is used inside Token::simpleMatch or Token::findsimplematch

Referenced by runChecks().

◆ checkUnknownPattern()

void CheckInternal::checkUnknownPattern ( )
private

Check for unknown (invalid) complex patterns like "%typ%"

Referenced by runChecks().

◆ classInfo()

std::string CheckInternal::classInfo ( ) const
inlineoverrideprivatevirtual

get information about this class, used to generate documentation

Implements Check.

Definition at line 114 of file checkinternal.h.

◆ complexPatternError()

void CheckInternal::complexPatternError ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ extraWhitespaceError()

void CheckInternal::extraWhitespaceError ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ getErrorMessages()

void CheckInternal::getErrorMessages ( ErrorLogger errorLogger,
const Settings settings 
) const
inlineoverrideprivatevirtual

◆ missingPercentCharacterError()

void CheckInternal::missingPercentCharacterError ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ multiComparePatternError()

void CheckInternal::multiComparePatternError ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ myName()

static std::string CheckInternal::myName ( )
inlinestaticprivate

Definition at line 110 of file checkinternal.h.

◆ orInComplexPattern()

void CheckInternal::orInComplexPattern ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ redundantNextPreviousError()

void CheckInternal::redundantNextPreviousError ( const Token tok,
const std::string &  func1,
const std::string &  func2 
)
private

Referenced by getErrorMessages().

◆ runChecks()

void CheckInternal::runChecks ( const Tokenizer ,
ErrorLogger  
)
inlineoverrideprivatevirtual

◆ simplePatternError()

void CheckInternal::simplePatternError ( const Token tok,
const std::string &  pattern,
const std::string &  funcname 
)
private

Referenced by getErrorMessages().

◆ unknownPatternError()

void CheckInternal::unknownPatternError ( const Token tok,
const std::string &  pattern 
)
private

Referenced by getErrorMessages().


The documentation for this class was generated from the following file: