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

Various small checks. More...

#include <checktype.h>

Inheritance diagram for CheckType:
Check

Public Member Functions

 CheckType ()
 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

 CheckType (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 against the normal token list. More...
 
void checkTooBigBitwiseShift ()
 Check for bitwise shift with too big right operand More...
 
void checkIntegerOverflow ()
 Check for integer overflow More...
 
void checkSignConversion ()
 Check for dangerous sign conversion More...
 
void checkLongCast ()
 Check for implicit long cast of int result More...
 
void checkFloatToIntegerOverflow ()
 Check for float to integer overflow More...
 
void checkFloatToIntegerOverflow (const Token *tok, const ValueType *vtint, const ValueType *vtfloat, const std::list< ValueFlow::Value > &floatValues)
 
void tooBigBitwiseShiftError (const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
 
void tooBigSignedBitwiseShiftError (const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
 
void integerOverflowError (const Token *tok, const ValueFlow::Value &value)
 
void signConversionError (const Token *tok, const ValueFlow::Value *negativeValue, const bool constvalue)
 
void longCastAssignError (const Token *tok, const ValueType *src=nullptr, const ValueType *tgt=nullptr)
 
void longCastReturnError (const Token *tok, const ValueType *src=nullptr, const ValueType *tgt=nullptr)
 
void floatToIntegerOverflowError (const Token *tok, const ValueFlow::Value &value)
 
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

Various small checks.

Definition at line 44 of file checktype.h.

Constructor & Destructor Documentation

◆ CheckType() [1/2]

CheckType::CheckType ( )
inline

This constructor is used when registering the CheckClass.

Definition at line 47 of file checktype.h.

◆ CheckType() [2/2]

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

This constructor is used when running checks.

Definition at line 51 of file checktype.h.

Member Function Documentation

◆ checkFloatToIntegerOverflow() [1/2]

void CheckType::checkFloatToIntegerOverflow ( )
private

◆ checkFloatToIntegerOverflow() [2/2]

void CheckType::checkFloatToIntegerOverflow ( const Token tok,
const ValueType vtint,
const ValueType vtfloat,
const std::list< ValueFlow::Value > &  floatValues 
)
private

◆ checkIntegerOverflow()

void CheckType::checkIntegerOverflow ( )
private

◆ checkLongCast()

void CheckType::checkLongCast ( )
private

◆ checkSignConversion()

void CheckType::checkSignConversion ( )
private

◆ checkTooBigBitwiseShift()

void CheckType::checkTooBigBitwiseShift ( )
private

◆ classInfo()

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

get information about this class, used to generate documentation

Implements Check.

Definition at line 108 of file checktype.h.

◆ floatToIntegerOverflowError()

void CheckType::floatToIntegerOverflowError ( const Token tok,
const ValueFlow::Value value 
)
private

◆ getErrorMessages()

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

◆ integerOverflowError()

void CheckType::integerOverflowError ( const Token tok,
const ValueFlow::Value value 
)
private

◆ longCastAssignError()

void CheckType::longCastAssignError ( const Token tok,
const ValueType src = nullptr,
const ValueType tgt = nullptr 
)
private

◆ longCastReturnError()

void CheckType::longCastReturnError ( const Token tok,
const ValueType src = nullptr,
const ValueType tgt = nullptr 
)
private

◆ myName()

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

Definition at line 104 of file checktype.h.

◆ runChecks()

void CheckType::runChecks ( const Tokenizer tokenizer,
ErrorLogger errorLogger 
)
inlineoverrideprivatevirtual

Run checks against the normal token list.

Implements Check.

Definition at line 55 of file checktype.h.

References checkFloatToIntegerOverflow(), checkIntegerOverflow(), checkLongCast(), checkSignConversion(), checkTooBigBitwiseShift(), and Tokenizer::getSettings().

◆ signConversionError()

void CheckType::signConversionError ( const Token tok,
const ValueFlow::Value negativeValue,
const bool  constvalue 
)
private

◆ tooBigBitwiseShiftError()

void CheckType::tooBigBitwiseShiftError ( const Token tok,
int  lhsbits,
const ValueFlow::Value rhsbits 
)
private

◆ tooBigSignedBitwiseShiftError()

void CheckType::tooBigSignedBitwiseShiftError ( const Token tok,
int  lhsbits,
const ValueFlow::Value rhsbits 
)
private

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