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

Various small checks. More...

#include <checkother.h>

Inheritance diagram for CheckOther:
Check

Public Member Functions

 CheckOther ()
 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 &)
 

Static Public Member Functions

static bool comparisonNonZeroExpressionLessThanZero (const Token *tok, const ValueFlow::Value *&zeroValue, const Token *&nonZeroExpr, bool suppress=false)
 Is expression a comparison that checks if a nonzero (unsigned/pointer) expression is less than zero? More...
 
static bool testIfNonZeroExpressionIsPositive (const Token *tok, const ValueFlow::Value *&zeroValue, const Token *&nonZeroExpr)
 Is expression a comparison that checks if a nonzero (unsigned/pointer) expression is positive? More...
 
- 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...
 

Private Member Functions

 CheckOther (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 clarifyCalculation ()
 Clarify calculation for ".. a * b ? ..". More...
 
void clarifyStatement ()
 Suspicious statement like '*A++;'. More...
 
void warningOldStylePointerCast ()
 Are there C-style pointer casts in a c++ file? More...
 
void invalidPointerCast ()
 Check for pointer casts to a type with an incompatible binary data representation. More...
 
void checkVariableScope ()
 Check scope of variables More...
 
bool checkInnerScope (const Token *tok, const Variable *var, bool &used) const
 
void checkCommaSeparatedReturn ()
 Check for comma separated statements in return More...
 
void checkPassByReference ()
 Check for function parameters that should be passed by reference More...
 
void checkConstVariable ()
 
void checkConstPointer ()
 
void checkCharVariable ()
 Using char variable as array index / as operand in bit operation. More...
 
void checkIncompleteStatement ()
 Incomplete statement. More...
 
void checkZeroDivision ()
 Check zero division More...
 
void checkNanInArithmeticExpression ()
 Check for NaN (not-a-number) in an arithmetic expression. More...
 
void checkRedundantAssignment ()
 copying to memory or assigning to a variable twice More...
 
void redundantBitwiseOperationInSwitchError ()
 Check for redundant bitwise operation in switch statement More...
 
void checkSuspiciousCaseInSwitch ()
 Check for code like 'case A||B:' More...
 
void checkMisusedScopedObject ()
 Check for objects that are destroyed immediately More...
 
void checkDuplicateBranch ()
 Check for suspicious code where if and else branch are the same (e.g "if (a) b = true; else b = true;") More...
 
void checkDuplicateExpression ()
 Check for suspicious code with the same expression on both sides of operator (e.g "if (a && a)") More...
 
void checkUnreachableCode ()
 Check for code that gets never executed, such as duplicate break statements More...
 
void checkSignOfUnsignedVariable ()
 Check for testing sign of unsigned variable More...
 
void checkSuspiciousSemicolon ()
 Check for suspicious use of semicolon More...
 
void checkInvalidFree ()
 Check for free() operations on invalid memory locations More...
 
void invalidFreeError (const Token *tok, const std::string &allocation, bool inconclusive)
 
void checkRedundantCopy ()
 Check for code creating redundant copies More...
 
void checkNegativeBitwiseShift ()
 Check for bitwise shift with negative right operand More...
 
void checkIncompleteArrayFill ()
 Check for buffers that are filled incompletely with memset and similar functions More...
 
void checkVarFuncNullUB ()
 Check that variadic function calls don't use NULL. More...
 
void checkCastIntToCharAndBack ()
 Check to avoid casting a return value to unsigned char and then back to integer type. More...
 
void checkComparisonFunctionIsAlwaysTrueOrFalse ()
 Check for using of comparison functions evaluating always to true or false. More...
 
void checkRedundantPointerOp ()
 Check for redundant pointer operations More...
 
void checkInterlockedDecrement ()
 Check for race condition with non-interlocked access after InterlockedDecrement() More...
 
void checkUnusedLabel ()
 Check for unused labels More...
 
void checkEvaluationOrder ()
 Check for expression that depends on order of evaluation of side effects More...
 
void checkAccessOfMovedVariable ()
 Check for access of moved or forwarded variable More...
 
void checkFuncArgNamesDifferent ()
 Check if function declaration and definition argument names different More...
 
void checkShadowVariables ()
 Check for shadow variables. More...
 
void checkKnownArgument ()
 
void checkKnownPointerToBool ()
 
void checkComparePointers ()
 
void checkModuloOfOne ()
 
void checkOverlappingWrite ()
 
void overlappingWriteUnion (const Token *tok)
 
void overlappingWriteFunction (const Token *tok)
 
void checkComparisonFunctionIsAlwaysTrueOrFalseError (const Token *tok, const std::string &functionName, const std::string &varName, const bool result)
 
void checkCastIntToCharAndBackError (const Token *tok, const std::string &strFunctionName)
 
void clarifyCalculationError (const Token *tok, const std::string &op)
 
void clarifyStatementError (const Token *tok)
 
void cstyleCastError (const Token *tok, bool isPtr=true)
 
void invalidPointerCastError (const Token *tok, const std::string &from, const std::string &to, bool inconclusive, bool toIsInt)
 
void passedByValueError (const Variable *var, bool inconclusive, bool isRangeBasedFor=false)
 
void constVariableError (const Variable *var, const Function *function)
 
void constStatementError (const Token *tok, const std::string &type, bool inconclusive)
 
void signedCharArrayIndexError (const Token *tok)
 
void unknownSignCharArrayIndexError (const Token *tok)
 
void charBitOpError (const Token *tok)
 
void variableScopeError (const Token *tok, const std::string &varname)
 
void zerodivError (const Token *tok, const ValueFlow::Value *value)
 
void nanInArithmeticExpressionError (const Token *tok)
 
void redundantAssignmentError (const Token *tok1, const Token *tok2, const std::string &var, bool inconclusive)
 
void redundantInitializationError (const Token *tok1, const Token *tok2, const std::string &var, bool inconclusive)
 
void redundantAssignmentInSwitchError (const Token *tok1, const Token *tok2, const std::string &var)
 
void redundantCopyError (const Token *tok1, const Token *tok2, const std::string &var)
 
void redundantBitwiseOperationInSwitchError (const Token *tok, const std::string &varname)
 
void suspiciousCaseInSwitchError (const Token *tok, const std::string &operatorString)
 
void selfAssignmentError (const Token *tok, const std::string &varname)
 
void misusedScopeObjectError (const Token *tok, const std::string &varname, bool isAssignment=false)
 
void duplicateBranchError (const Token *tok1, const Token *tok2, ErrorPath errors)
 
void duplicateAssignExpressionError (const Token *tok1, const Token *tok2, bool inconclusive)
 
void oppositeExpressionError (const Token *opTok, ErrorPath errors)
 
void duplicateExpressionError (const Token *tok1, const Token *tok2, const Token *opTok, ErrorPath errors, bool hasMultipleExpr=false)
 
void duplicateValueTernaryError (const Token *tok)
 
void duplicateExpressionTernaryError (const Token *tok, ErrorPath errors)
 
void duplicateBreakError (const Token *tok, bool inconclusive)
 
void unreachableCodeError (const Token *tok, const Token *noreturn, bool inconclusive)
 
void redundantContinueError (const Token *tok)
 
void unsignedLessThanZeroError (const Token *tok, const ValueFlow::Value *v, const std::string &varname)
 
void pointerLessThanZeroError (const Token *tok, const ValueFlow::Value *v)
 
void unsignedPositiveError (const Token *tok, const ValueFlow::Value *v, const std::string &varname)
 
void pointerPositiveError (const Token *tok, const ValueFlow::Value *v)
 
void suspiciousSemicolonError (const Token *tok)
 
void negativeBitwiseShiftError (const Token *tok, int op)
 
void redundantCopyError (const Token *tok, const std::string &varname)
 
void incompleteArrayFillError (const Token *tok, const std::string &buffer, const std::string &function, bool boolean)
 
void varFuncNullUBError (const Token *tok)
 
void commaSeparatedReturnError (const Token *tok)
 
void redundantPointerOpError (const Token *tok, const std::string &varname, bool inconclusive, bool addressOfDeref)
 
void raceAfterInterlockedDecrementError (const Token *tok)
 
void unusedLabelError (const Token *tok, bool inSwitch, bool hasIfdef)
 
void unknownEvaluationOrder (const Token *tok)
 
void accessMovedError (const Token *tok, const std::string &varname, const ValueFlow::Value *value, bool inconclusive)
 
void funcArgNamesDifferent (const std::string &functionName, nonneg int index, const Token *declaration, const Token *definition)
 
void funcArgOrderDifferent (const std::string &functionName, const Token *declaration, const Token *definition, const std::vector< const Token * > &declarations, const std::vector< const Token * > &definitions)
 
void shadowError (const Token *var, const Token *shadowed, const std::string &type)
 
void knownArgumentError (const Token *tok, const Token *ftok, const ValueFlow::Value *value, const std::string &varexpr, bool isVariableExpressionHidden)
 
void knownPointerToBoolError (const Token *tok, const ValueFlow::Value *value)
 
void comparePointersError (const Token *tok, const ValueFlow::Value *v1, const ValueFlow::Value *v2)
 
void checkModuloOfOneError (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 ()
 

Friends

class TestCharVar
 
class TestIncompleteStatement
 
class TestOther
 

Additional Inherited Members

- 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 49 of file checkother.h.

Constructor & Destructor Documentation

◆ CheckOther() [1/2]

CheckOther::CheckOther ( )
inline

This constructor is used when registering the CheckClass.

Definition at line 56 of file checkother.h.

◆ CheckOther() [2/2]

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

This constructor is used when running checks.

Definition at line 66 of file checkother.h.

Member Function Documentation

◆ accessMovedError()

void CheckOther::accessMovedError ( const Token tok,
const std::string &  varname,
const ValueFlow::Value value,
bool  inconclusive 
)
private

◆ charBitOpError()

void CheckOther::charBitOpError ( const Token tok)
private

Definition at line 1733 of file checkother.cpp.

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

Referenced by checkCharVariable(), and getErrorMessages().

◆ checkAccessOfMovedVariable()

void CheckOther::checkAccessOfMovedVariable ( )
private

◆ checkCastIntToCharAndBack()

void CheckOther::checkCastIntToCharAndBack ( )
private

◆ checkCastIntToCharAndBackError()

void CheckOther::checkCastIntToCharAndBackError ( const Token tok,
const std::string &  strFunctionName 
)
private

Definition at line 134 of file checkother.cpp.

References CWE197, normal, Check::reportError(), and warning.

Referenced by checkCastIntToCharAndBack(), and getErrorMessages().

◆ checkCharVariable()

void CheckOther::checkCharVariable ( )
private

◆ checkCommaSeparatedReturn()

void CheckOther::checkCommaSeparatedReturn ( )
private

◆ checkComparePointers()

void CheckOther::checkComparePointers ( )
private

◆ checkComparisonFunctionIsAlwaysTrueOrFalse()

void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse ( )
private

◆ checkComparisonFunctionIsAlwaysTrueOrFalseError()

void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError ( const Token tok,
const std::string &  functionName,
const std::string &  varName,
const bool  result 
)
private

◆ checkConstPointer()

void CheckOther::checkConstPointer ( )
private

◆ checkConstVariable()

void CheckOther::checkConstVariable ( )
private

◆ checkDuplicateBranch()

void CheckOther::checkDuplicateBranch ( )
private

◆ checkDuplicateExpression()

void CheckOther::checkDuplicateExpression ( )
private

◆ checkEvaluationOrder()

void CheckOther::checkEvaluationOrder ( )
private

◆ checkFuncArgNamesDifferent()

void CheckOther::checkFuncArgNamesDifferent ( )
private

◆ checkIncompleteArrayFill()

void CheckOther::checkIncompleteArrayFill ( )
private

◆ checkIncompleteStatement()

void CheckOther::checkIncompleteStatement ( )
private

◆ checkInnerScope()

bool CheckOther::checkInnerScope ( const Token tok,
const Variable var,
bool &  used 
) const
private

◆ checkInterlockedDecrement()

void CheckOther::checkInterlockedDecrement ( )
private

Check for race condition with non-interlocked access after InterlockedDecrement()

Definition at line 3174 of file checkother.cpp.

References Platform::isWindows(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::platform, raceAfterInterlockedDecrementError(), Token::str(), Token::strAt(), Token::tokAt(), and Tokenizer::tokens().

Referenced by runChecks().

◆ checkInvalidFree()

void CheckOther::checkInvalidFree ( )
private

◆ checkKnownArgument()

void CheckOther::checkKnownArgument ( )
private

◆ checkKnownPointerToBool()

void CheckOther::checkKnownPointerToBool ( )
private

◆ checkMisusedScopedObject()

void CheckOther::checkMisusedScopedObject ( )
private

◆ checkModuloOfOne()

void CheckOther::checkModuloOfOne ( )
private

◆ checkModuloOfOneError()

void CheckOther::checkModuloOfOneError ( const Token tok)
private

Definition at line 3875 of file checkother.cpp.

References Check::reportError(), and style.

Referenced by checkModuloOfOne(), and getErrorMessages().

◆ checkNanInArithmeticExpression()

void CheckOther::checkNanInArithmeticExpression ( )
private

◆ checkNegativeBitwiseShift()

void CheckOther::checkNegativeBitwiseShift ( )
private

◆ checkOverlappingWrite()

void CheckOther::checkOverlappingWrite ( )
private

◆ checkPassByReference()

void CheckOther::checkPassByReference ( )
private

◆ checkRedundantAssignment()

void CheckOther::checkRedundantAssignment ( )
private

◆ checkRedundantCopy()

void CheckOther::checkRedundantCopy ( )
private

◆ checkRedundantPointerOp()

void CheckOther::checkRedundantPointerOp ( )
private

◆ checkShadowVariables()

void CheckOther::checkShadowVariables ( )
private

◆ checkSignOfUnsignedVariable()

void CheckOther::checkSignOfUnsignedVariable ( )
private

◆ checkSuspiciousCaseInSwitch()

void CheckOther::checkSuspiciousCaseInSwitch ( )
private

◆ checkSuspiciousSemicolon()

void CheckOther::checkSuspiciousSemicolon ( )
private

◆ checkUnreachableCode()

void CheckOther::checkUnreachableCode ( )
private

◆ checkUnusedLabel()

void CheckOther::checkUnusedLabel ( )
private

◆ checkVarFuncNullUB()

void CheckOther::checkVarFuncNullUB ( )
private

◆ checkVariableScope()

void CheckOther::checkVariableScope ( )
private

◆ checkZeroDivision()

void CheckOther::checkZeroDivision ( )
private

◆ clarifyCalculation()

void CheckOther::clarifyCalculation ( )
private

◆ clarifyCalculationError()

void CheckOther::clarifyCalculationError ( const Token tok,
const std::string &  op 
)
private

Definition at line 203 of file checkother.cpp.

References CWE783, normal, Check::reportError(), and style.

Referenced by clarifyCalculation(), and getErrorMessages().

◆ clarifyStatement()

void CheckOther::clarifyStatement ( )
private

◆ clarifyStatementError()

void CheckOther::clarifyStatementError ( const Token tok)
private

Definition at line 251 of file checkother.cpp.

References CWE783, normal, Check::reportError(), and warning.

Referenced by clarifyStatement(), and getErrorMessages().

◆ classInfo()

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

get information about this class, used to generate documentation

Implements Check.

Definition at line 371 of file checkother.h.

◆ commaSeparatedReturnError()

void CheckOther::commaSeparatedReturnError ( const Token tok)
private

Definition at line 1203 of file checkother.cpp.

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

Referenced by checkCommaSeparatedReturn(), and getErrorMessages().

◆ comparePointersError()

void CheckOther::comparePointersError ( const Token tok,
const ValueFlow::Value v1,
const ValueFlow::Value v2 
)
private

◆ comparisonNonZeroExpressionLessThanZero()

bool CheckOther::comparisonNonZeroExpressionLessThanZero ( const Token tok,
const ValueFlow::Value *&  zeroValue,
const Token *&  nonZeroExpr,
bool  suppress = false 
)
static

Is expression a comparison that checks if a nonzero (unsigned/pointer) expression is less than zero?

Definition at line 2748 of file checkother.cpp.

References Token::astOperand1(), Token::astOperand2(), Token::isComparisonOp(), ValueFlow::Value::isKnown(), Token::Match(), ValueType::pointer, ValueType::sign, ValueType::UNSIGNED, Token::valueType(), and Token::variable().

Referenced by CheckCondition::alwaysTrueFalse(), and checkSignOfUnsignedVariable().

◆ constStatementError()

void CheckOther::constStatementError ( const Token tok,
const std::string &  type,
bool  inconclusive 
)
private

◆ constVariableError()

void CheckOther::constVariableError ( const Variable var,
const Function function 
)
private

◆ cstyleCastError()

void CheckOther::cstyleCastError ( const Token tok,
bool  isPtr = true 
)
private

Definition at line 357 of file checkother.cpp.

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

Referenced by getErrorMessages(), and warningOldStylePointerCast().

◆ duplicateAssignExpressionError()

void CheckOther::duplicateAssignExpressionError ( const Token tok1,
const Token tok2,
bool  inconclusive 
)
private

◆ duplicateBranchError()

void CheckOther::duplicateBranchError ( const Token tok1,
const Token tok2,
ErrorPath  errors 
)
private

Definition at line 2263 of file checkother.cpp.

References CWE398, inconclusive, Check::reportError(), and style.

Referenced by checkDuplicateBranch(), and getErrorMessages().

◆ duplicateBreakError()

void CheckOther::duplicateBreakError ( const Token tok,
bool  inconclusive 
)
private

Definition at line 881 of file checkother.cpp.

References CWE561, inconclusive, normal, Check::reportError(), and style.

Referenced by checkUnreachableCode(), and getErrorMessages().

◆ duplicateExpressionError()

void CheckOther::duplicateExpressionError ( const Token tok1,
const Token tok2,
const Token opTok,
ErrorPath  errors,
bool  hasMultipleExpr = false 
)
private

◆ duplicateExpressionTernaryError()

void CheckOther::duplicateExpressionTernaryError ( const Token tok,
ErrorPath  errors 
)
private

Definition at line 2640 of file checkother.cpp.

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

Referenced by checkDuplicateExpression(), and getErrorMessages().

◆ duplicateValueTernaryError()

void CheckOther::duplicateValueTernaryError ( const Token tok)
private

Definition at line 2648 of file checkother.cpp.

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

Referenced by checkDuplicateExpression(), and getErrorMessages().

◆ funcArgNamesDifferent()

void CheckOther::funcArgNamesDifferent ( const std::string &  functionName,
nonneg int  index,
const Token declaration,
const Token definition 
)
private

◆ funcArgOrderDifferent()

void CheckOther::funcArgOrderDifferent ( const std::string &  functionName,
const Token declaration,
const Token definition,
const std::vector< const Token * > &  declarations,
const std::vector< const Token * > &  definitions 
)
private

Definition at line 3520 of file checkother.cpp.

References CWE683, normal, Check::reportError(), Token::str(), and warning.

Referenced by checkFuncArgNamesDifferent(), and getErrorMessages().

◆ getErrorMessages()

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

get error messages

Implements Check.

Definition at line 293 of file checkother.h.

References accessMovedError(), charBitOpError(), checkCastIntToCharAndBackError(), checkComparisonFunctionIsAlwaysTrueOrFalseError(), checkModuloOfOneError(), clarifyCalculationError(), clarifyStatementError(), commaSeparatedReturnError(), comparePointersError(), constStatementError(), constVariableError(), cstyleCastError(), duplicateAssignExpressionError(), duplicateBranchError(), duplicateBreakError(), duplicateExpressionError(), duplicateExpressionTernaryError(), duplicateValueTernaryError(), funcArgNamesDifferent(), funcArgOrderDifferent(), incompleteArrayFillError(), invalidFreeError(), invalidPointerCastError(), knownArgumentError(), knownPointerToBoolError(), misusedScopeObjectError(), nanInArithmeticExpressionError(), negativeBitwiseShiftError(), oppositeExpressionError(), overlappingWriteFunction(), overlappingWriteUnion(), passedByValueError(), pointerLessThanZeroError(), pointerPositiveError(), raceAfterInterlockedDecrementError(), redundantAssignmentError(), redundantAssignmentInSwitchError(), redundantBitwiseOperationInSwitchError(), redundantCopyError(), redundantInitializationError(), redundantPointerOpError(), selfAssignmentError(), shadowError(), signedCharArrayIndexError(), suspiciousCaseInSwitchError(), suspiciousSemicolonError(), unknownEvaluationOrder(), unknownSignCharArrayIndexError(), unreachableCodeError(), unsignedLessThanZeroError(), unsignedPositiveError(), unusedLabelError(), varFuncNullUBError(), variableScopeError(), and zerodivError().

◆ incompleteArrayFillError()

void CheckOther::incompleteArrayFillError ( const Token tok,
const std::string &  buffer,
const std::string &  function,
bool  boolean 
)
private

◆ invalidFreeError()

void CheckOther::invalidFreeError ( const Token tok,
const std::string &  allocation,
bool  inconclusive 
)
private

Definition at line 2354 of file checkother.cpp.

References CWE, error, inconclusive, normal, and Check::reportError().

Referenced by checkInvalidFree(), and getErrorMessages().

◆ invalidPointerCast()

void CheckOther::invalidPointerCast ( )
private

◆ invalidPointerCastError()

void CheckOther::invalidPointerCastError ( const Token tok,
const std::string &  from,
const std::string &  to,
bool  inconclusive,
bool  toIsInt 
)
private

Definition at line 412 of file checkother.cpp.

References CWE704, inconclusive, normal, portability, and Check::reportError().

Referenced by getErrorMessages(), and invalidPointerCast().

◆ knownArgumentError()

void CheckOther::knownArgumentError ( const Token tok,
const Token ftok,
const ValueFlow::Value value,
const std::string &  varexpr,
bool  isVariableExpressionHidden 
)
private

◆ knownPointerToBoolError()

void CheckOther::knownPointerToBoolError ( const Token tok,
const ValueFlow::Value value 
)
private

◆ misusedScopeObjectError()

void CheckOther::misusedScopeObjectError ( const Token tok,
const std::string &  varname,
bool  isAssignment = false 
)
private

Definition at line 2157 of file checkother.cpp.

References CWE563, normal, Check::reportError(), and style.

Referenced by checkMisusedScopedObject(), and getErrorMessages().

◆ myName()

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

Definition at line 367 of file checkother.h.

◆ nanInArithmeticExpressionError()

void CheckOther::nanInArithmeticExpressionError ( const Token tok)
private

Definition at line 2071 of file checkother.cpp.

References CWE369, normal, Check::reportError(), and style.

Referenced by checkNanInArithmeticExpression(), and getErrorMessages().

◆ negativeBitwiseShiftError()

void CheckOther::negativeBitwiseShiftError ( const Token tok,
int  op 
)
private

Definition at line 2963 of file checkother.cpp.

References CWE758, error, normal, portability, and Check::reportError().

Referenced by checkNegativeBitwiseShift(), and getErrorMessages().

◆ oppositeExpressionError()

void CheckOther::oppositeExpressionError ( const Token opTok,
ErrorPath  errors 
)
private

Definition at line 2586 of file checkother.cpp.

References CWE398, normal, Check::reportError(), Token::str(), and style.

Referenced by checkDuplicateExpression(), and getErrorMessages().

◆ overlappingWriteFunction()

void CheckOther::overlappingWriteFunction ( const Token tok)
private

Definition at line 4044 of file checkother.cpp.

References emptyString, error, Check::reportError(), and Token::str().

Referenced by checkOverlappingWrite(), and getErrorMessages().

◆ overlappingWriteUnion()

void CheckOther::overlappingWriteUnion ( const Token tok)
private

Definition at line 4039 of file checkother.cpp.

References error, and Check::reportError().

Referenced by checkOverlappingWrite(), and getErrorMessages().

◆ passedByValueError()

void CheckOther::passedByValueError ( const Variable var,
bool  inconclusive,
bool  isRangeBasedFor = false 
)
private

◆ pointerLessThanZeroError()

void CheckOther::pointerLessThanZeroError ( const Token tok,
const ValueFlow::Value v 
)
private

◆ pointerPositiveError()

void CheckOther::pointerPositiveError ( const Token tok,
const ValueFlow::Value v 
)
private

◆ raceAfterInterlockedDecrementError()

void CheckOther::raceAfterInterlockedDecrementError ( const Token tok)
private

Definition at line 3214 of file checkother.cpp.

References CWE362, error, normal, and Check::reportError().

Referenced by checkInterlockedDecrement(), and getErrorMessages().

◆ redundantAssignmentError()

void CheckOther::redundantAssignmentError ( const Token tok1,
const Token tok2,
const std::string &  var,
bool  inconclusive 
)
private

Definition at line 550 of file checkother.cpp.

References CWE563, inconclusive, normal, Check::reportError(), and style.

Referenced by checkRedundantAssignment(), and getErrorMessages().

◆ redundantAssignmentInSwitchError()

void CheckOther::redundantAssignmentInSwitchError ( const Token tok1,
const Token tok2,
const std::string &  var 
)
private

Definition at line 573 of file checkother.cpp.

References CWE563, normal, Check::reportError(), and style.

Referenced by checkRedundantAssignment(), and getErrorMessages().

◆ redundantBitwiseOperationInSwitchError() [1/2]

void CheckOther::redundantBitwiseOperationInSwitchError ( )
private

◆ redundantBitwiseOperationInSwitchError() [2/2]

void CheckOther::redundantBitwiseOperationInSwitchError ( const Token tok,
const std::string &  varname 
)
private

Definition at line 713 of file checkother.cpp.

References Check::reportError(), and style.

◆ redundantContinueError()

void CheckOther::redundantContinueError ( const Token tok)
private

Definition at line 903 of file checkother.cpp.

References CWE561, normal, Check::reportError(), and style.

Referenced by checkUnreachableCode().

◆ redundantCopyError() [1/2]

void CheckOther::redundantCopyError ( const Token tok,
const std::string &  varname 
)
private

Definition at line 2903 of file checkother.cpp.

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

◆ redundantCopyError() [2/2]

void CheckOther::redundantCopyError ( const Token tok1,
const Token tok2,
const std::string &  var 
)
private

Definition at line 542 of file checkother.cpp.

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

Referenced by checkRedundantCopy(), and getErrorMessages().

◆ redundantInitializationError()

void CheckOther::redundantInitializationError ( const Token tok1,
const Token tok2,
const std::string &  var,
bool  inconclusive 
)
private

Definition at line 564 of file checkother.cpp.

References CWE563, inconclusive, normal, Check::reportError(), and style.

Referenced by checkRedundantAssignment(), and getErrorMessages().

◆ redundantPointerOpError()

void CheckOther::redundantPointerOpError ( const Token tok,
const std::string &  varname,
bool  inconclusive,
bool  addressOfDeref 
)
private

Definition at line 3167 of file checkother.cpp.

References CWE398, inconclusive, normal, Check::reportError(), and style.

Referenced by checkRedundantPointerOp(), and getErrorMessages().

◆ runChecks()

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

◆ selfAssignmentError()

void CheckOther::selfAssignmentError ( const Token tok,
const std::string &  varname 
)
private

◆ shadowError()

void CheckOther::shadowError ( const Token var,
const Token shadowed,
const std::string &  type 
)
private

Definition at line 3613 of file checkother.cpp.

References CWE398, normal, Check::reportError(), Token::str(), and style.

Referenced by checkShadowVariables(), and getErrorMessages().

◆ signedCharArrayIndexError()

void CheckOther::signedCharArrayIndexError ( const Token tok)
private

Definition at line 1712 of file checkother.cpp.

References CWE128, normal, Check::reportError(), and warning.

Referenced by checkCharVariable(), and getErrorMessages().

◆ suspiciousCaseInSwitchError()

void CheckOther::suspiciousCaseInSwitchError ( const Token tok,
const std::string &  operatorString 
)
private

Definition at line 759 of file checkother.cpp.

References CWE398, inconclusive, Check::reportError(), and warning.

Referenced by checkSuspiciousCaseInSwitch(), and getErrorMessages().

◆ suspiciousSemicolonError()

void CheckOther::suspiciousSemicolonError ( const Token tok)
private

Definition at line 285 of file checkother.cpp.

References CWE398, normal, Check::reportError(), Token::str(), and warning.

Referenced by checkSuspiciousSemicolon(), and getErrorMessages().

◆ testIfNonZeroExpressionIsPositive()

bool CheckOther::testIfNonZeroExpressionIsPositive ( const Token tok,
const ValueFlow::Value *&  zeroValue,
const Token *&  nonZeroExpr 
)
static

Is expression a comparison that checks if a nonzero (unsigned/pointer) expression is positive?

Definition at line 2774 of file checkother.cpp.

References Token::astOperand1(), Token::astOperand2(), Token::isComparisonOp(), ValueFlow::Value::isKnown(), ValueType::pointer, ValueType::sign, Token::simpleMatch(), ValueType::UNSIGNED, and Token::valueType().

Referenced by CheckCondition::alwaysTrueFalse(), and checkSignOfUnsignedVariable().

◆ unknownEvaluationOrder()

void CheckOther::unknownEvaluationOrder ( const Token tok)
private

◆ unknownSignCharArrayIndexError()

void CheckOther::unknownSignCharArrayIndexError ( const Token tok)
private

Definition at line 1723 of file checkother.cpp.

References CWE758, normal, portability, and Check::reportError().

Referenced by checkCharVariable(), and getErrorMessages().

◆ unreachableCodeError()

void CheckOther::unreachableCodeError ( const Token tok,
const Token noreturn,
bool  inconclusive 
)
private

◆ unsignedLessThanZeroError()

void CheckOther::unsignedLessThanZeroError ( const Token tok,
const ValueFlow::Value v,
const std::string &  varname 
)
private

◆ unsignedPositiveError()

void CheckOther::unsignedPositiveError ( const Token tok,
const ValueFlow::Value v,
const std::string &  varname 
)
private

◆ unusedLabelError()

void CheckOther::unusedLabelError ( const Token tok,
bool  inSwitch,
bool  hasIfdef 
)
private

◆ varFuncNullUBError()

void CheckOther::varFuncNullUBError ( const Token tok)
private

Definition at line 3081 of file checkother.cpp.

References CWE475, normal, portability, and Check::reportError().

Referenced by checkVarFuncNullUB(), and getErrorMessages().

◆ variableScopeError()

void CheckOther::variableScopeError ( const Token tok,
const std::string &  varname 
)
private

Definition at line 1149 of file checkother.cpp.

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

Referenced by checkVariableScope(), and getErrorMessages().

◆ warningOldStylePointerCast()

void CheckOther::warningOldStylePointerCast ( )
private

◆ zerodivError()

void CheckOther::zerodivError ( const Token tok,
const ValueFlow::Value value 
)
private

Friends And Related Function Documentation

◆ TestCharVar

friend class TestCharVar
friend

Definition at line 50 of file checkother.h.

◆ TestIncompleteStatement

friend class TestIncompleteStatement
friend

Definition at line 51 of file checkother.h.

◆ TestOther

friend class TestOther
friend

Definition at line 52 of file checkother.h.


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