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

Using postfix operators ++ or – rather than postfix operator. More...

#include <checkpostfixoperator.h>

Inheritance diagram for CheckPostfixOperator:
Check

Public Member Functions

 CheckPostfixOperator ()
 This constructor is used when registering the CheckPostfixOperator. 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

 CheckPostfixOperator (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 postfixOperator ()
 Check postfix operators. More...
 
void postfixOperatorError (const Token *tok)
 Report Error. More...
 
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 ()
 

Friends

class TestPostfixOperator
 

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

Using postfix operators ++ or – rather than postfix operator.

Definition at line 42 of file checkpostfixoperator.h.

Constructor & Destructor Documentation

◆ CheckPostfixOperator() [1/2]

CheckPostfixOperator::CheckPostfixOperator ( )
inline

This constructor is used when registering the CheckPostfixOperator.

Definition at line 47 of file checkpostfixoperator.h.

◆ CheckPostfixOperator() [2/2]

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

This constructor is used when running checks.

Definition at line 51 of file checkpostfixoperator.h.

Member Function Documentation

◆ classInfo()

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

get information about this class, used to generate documentation

Implements Check.

Definition at line 77 of file checkpostfixoperator.h.

◆ getErrorMessages()

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

get error messages

Implements Check.

Definition at line 68 of file checkpostfixoperator.h.

References postfixOperatorError().

◆ myName()

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

Definition at line 73 of file checkpostfixoperator.h.

◆ postfixOperator()

void CheckPostfixOperator::postfixOperator ( )
private

◆ postfixOperatorError()

void CheckPostfixOperator::postfixOperatorError ( const Token tok)
private

Report Error.

Definition at line 80 of file checkpostfixoperator.cpp.

References CWE398, normal, performance, and Check::reportError().

Referenced by getErrorMessages(), and postfixOperator().

◆ runChecks()

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

run checks, the token list is not simplified

Implements Check.

Definition at line 54 of file checkpostfixoperator.h.

References Tokenizer::getSettings(), Tokenizer::isC(), and postfixOperator().

Friends And Related Function Documentation

◆ TestPostfixOperator

friend class TestPostfixOperator
friend

Definition at line 43 of file checkpostfixoperator.h.


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