Cppcheck
|
Various small checks. More...
#include <checkother.h>
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 | |
Check & | operator= (const Check &)=delete |
const std::string & | name () const |
class name, used to generate documentation More... | |
virtual FileInfo * | getFileInfo (const Tokenizer &, const Settings &) const |
virtual FileInfo * | loadFileInfoFromXml (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 {} |
Various small checks.
Definition at line 49 of file checkother.h.
|
inline |
This constructor is used when registering the CheckClass.
Definition at line 56 of file checkother.h.
|
inlineprivate |
This constructor is used when running checks.
Definition at line 66 of file checkother.h.
|
private |
Definition at line 3397 of file checkother.cpp.
References CWE672, ValueFlow::Value::ForwardedVariable, Check::getErrorPath(), inconclusive, ValueFlow::Value::MovedVariable, ValueFlow::Value::moveKind, normal, Check::reportError(), and warning.
Referenced by checkAccessOfMovedVariable(), and getErrorMessages().
|
private |
Definition at line 1733 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and warning.
Referenced by checkCharVariable(), and getErrorMessages().
|
private |
Check for access of moved or forwarded variable
Definition at line 3350 of file checkother.cpp.
References accessMovedError(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Function::constructorMemberInitialization(), Standards::cpp, Standards::CPP11, Scope::function, SymbolDatabase::functionScopes, getExprUsage(), Tokenizer::getSymbolDatabase(), Inconclusive, inconclusive, Tokenizer::isCPP(), SimpleEnableGroup< T >::isEnabled(), ValueFlow::Value::isInconclusive(), Settings::isPremiumEnabled(), isVariableChangedByFunctionCall(), Check::logChecker(), ValueFlow::Value::moveKind, Check::mSettings, Check::mTokenizer, Token::next(), ValueFlow::Value::NonMovedVariable, PassedByReference, Settings::severity, Settings::standards, Used, and warning.
Referenced by runChecks().
|
private |
Check to avoid casting a return value to unsigned char and then back to integer type.
Definition at line 84 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, checkCastIntToCharAndBackError(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Token::isSigned(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, Token::str(), Variable::typeEndToken(), and warning.
Referenced by runChecks().
|
private |
Definition at line 134 of file checkother.cpp.
References CWE197, normal, Check::reportError(), and warning.
Referenced by checkCastIntToCharAndBack(), and getErrorMessages().
|
private |
Using char variable as array index / as operand in bit operation.
Definition at line 1661 of file checkother.cpp.
References astIsSignedChar(), astIsUnknownSignChar(), Token::astOperand2(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, charBitOpError(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), Token::getValueGE(), ValueFlow::Value::intvalue, SimpleEnableGroup< T >::isEnabled(), ValueFlow::Value::isKnown(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), portability, Settings::severity, signedCharArrayIndexError(), Token::simpleMatch(), ValueType::type, unknownSignCharArrayIndexError(), Token::valueType(), and warning.
Referenced by runChecks().
|
private |
Check for comma separated statements in return
Definition at line 1176 of file checkother.cpp.
References commaSeparatedReturnError(), SimpleEnableGroup< T >::isEnabled(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, style, and Tokenizer::tokens().
Referenced by runChecks().
|
private |
Definition at line 3796 of file checkother.cpp.
References astIsPointer(), Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, comparePointersError(), SymbolDatabase::functionScopes, ValueFlow::getLifetimeObjValue(), getParentLifetime(), Tokenizer::getSymbolDatabase(), ValueFlow::Value::isLocalLifetimeValue(), Variable::isReference(), Variable::isRValueReference(), Settings::library, Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), ValueFlow::Value::tokvalue, Token::variable(), and Token::varId().
Referenced by runChecks().
|
private |
Check for using of comparison functions evaluating always to true or false.
Definition at line 2672 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, checkComparisonFunctionIsAlwaysTrueOrFalseError(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, and warning.
Referenced by runChecks().
|
private |
Definition at line 2702 of file checkother.cpp.
References bool_to_string(), CWE570, CWE571, normal, Check::reportError(), and warning.
Referenced by checkComparisonFunctionIsAlwaysTrueOrFalse(), and getErrorMessages().
|
private |
Definition at line 1479 of file checkother.cpp.
References astIsRangeBasedForDecl(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), ValueType::constness, constVariableError(), Variable::declarationId(), Library::ArgumentChecks::DIR_IN, Library::getArgDirection(), getTokenArgumentFunction(), getVariableChangedStart(), inconclusive, Variable::isArgument(), Variable::isArray(), Token::isCast(), ValueType::isConst(), SimpleEnableGroup< T >::isEnabled(), Library::isFunctionConst(), Token::isIncDecOp(), Variable::isLocal(), Settings::isPremiumEnabled(), Variable::isStatic(), Token::isTemplateArg(), Token::isUnaryOp(), isVariableChanged(), isVariableChangedByFunctionCall(), Settings::library, Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Variable::nameToken(), Token::next(), None, ValueType::pointer, ValueType::reference, Function::returnsConst(), Function::returnsReference(), Token::scope(), Settings::severity, Token::simpleMatch(), style, Tokenizer::tokens(), Variable::typeStartToken(), Variable::valueType(), Token::valueType(), and Token::variable().
Referenced by runChecks().
|
private |
Definition at line 1329 of file checkother.cpp.
References astIsRangeBasedForDecl(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, constVariableError(), Function::findReturns(), Scope::function, Tokenizer::getSymbolDatabase(), getTokenArgumentFunction(), inconclusive, Token::isAssignmentOp(), Tokenizer::isC(), Token::isCalculation(), Token::isComparisonOp(), Variable::isConst(), ValueType::isConst(), SimpleEnableGroup< T >::isEnabled(), Scope::isLocal(), Settings::isPremiumEnabled(), Variable::isReference(), isStructuredBindingVariable(), Token::isUnaryOp(), isVariableChanged(), isVariableChangedByFunctionCall(), isVariableMutableInInitializer(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Variable::nameToken(), Scope::nestedIn, Token::next(), Function::returnsConst(), Function::returnsPointer(), Function::returnsReference(), Settings::severity, style, Token::valueType(), and SymbolDatabase::variableList().
Referenced by runChecks().
|
private |
Check for suspicious code where if and else branch are the same (e.g "if (a) b = true; else b = true;")
Definition at line 2184 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Scope::classDef, duplicateBranchError(), Scope::eIf, getSingleExpressionInBlock(), Tokenizer::getSymbolDatabase(), inconclusive, SimpleEnableGroup< T >::isEnabled(), isSameExpression(), Token::linkAt(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Token::next(), SymbolDatabase::scopeList, Settings::severity, Token::simpleMatch(), Token::str(), Token::stringify(), Token::stringifyList(), style, Token::tokAt(), and Scope::type.
Referenced by runChecks().
|
private |
Check for suspicious code with the same expression on both sides of operator (e.g "if (a && a)")
Definition at line 2397 of file checkother.cpp.
References astIsFloat(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, ValueType::constness, Standards::cpp, Standards::CPP11, duplicateAssignExpressionError(), duplicateExpressionError(), duplicateExpressionTernaryError(), duplicateValueTernaryError(), Scope::eEnum, Token::eType, findExpressionChanged(), Token::findsimplematch(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), inconclusive, isConstExpression(), isConstStatement(), isConstVarExpression(), SimpleEnableGroup< T >::isEnabled(), isEqualKnownValue(), isInLoopCondition(), isLambdaCaptureList(), isOppositeExpression(), Settings::isPremiumEnabled(), isSameExpression(), isUniqueExpression(), isVariableChanged(), isWithoutSideEffects(), Settings::library, Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), oppositeExpressionError(), ValueType::originalTypeName, ValueType::pointer, Token::previous(), Token::scope(), selfAssignmentError(), Settings::severity, Token::simpleMatch(), Settings::standards, Token::str(), style, Token::tokAt(), Token::valueType(), and Token::varId().
Referenced by runChecks().
|
private |
Check for expression that depends on order of evaluation of side effects
Definition at line 3269 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, Standards::cpp, Standards::CPP11, Token::eIncDecOp, SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), Tokenizer::isCPP(), SimpleEnableGroup< T >::isEnabled(), isSameExpression(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Token::nextArgument(), Token::previous(), selfAssignmentError(), Settings::severity, Token::simpleMatch(), Settings::standards, Token::str(), Token::strAt(), unknownEvaluationOrder(), visitAstNodes(), and warning.
Referenced by runChecks().
|
private |
Check if function declaration and definition argument names different
Definition at line 3426 of file checkother.cpp.
References Settings::certainty, funcArgNamesDifferent(), funcArgOrderDifferent(), Scope::function, SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), inconclusive, SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Variable::nameToken(), Token::next(), Token::nextArgument(), Settings::severity, Token::simpleMatch(), Token::str(), style, Token::varId(), and warning.
Referenced by runChecks().
|
private |
Check for buffers that are filled incompletely with memset and similar functions
Definition at line 2977 of file checkother.cpp.
References Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Variable::dimension(), Variable::dimensions(), Token::expressionString(), SymbolDatabase::functionScopes, ValueFlow::getSizeOf(), Tokenizer::getSymbolDatabase(), incompleteArrayFillError(), inconclusive, Variable::isArray(), SimpleEnableGroup< T >::isEnabled(), Variable::isPointer(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::platform, ValueType::pointer, portability, Settings::severity, Platform::sizeof_pointer, Tokenizer::sizeOfType(), Token::str(), MathLib::toBigNumber(), Token::tokAt(), ValueType::type, Variable::typeStartToken(), Variable::valueType(), Token::variable(), and warning.
Referenced by runChecks().
|
private |
Incomplete statement.
A statement that only contains a constant or variable
Definition at line 1897 of file checkother.cpp.
References Settings::certainty, constStatementError(), done, inconclusive, Token::isAssignmentOp(), isConstStatement(), isConstTop(), SimpleEnableGroup< T >::isEnabled(), Scope::isExecutable(), isVoidStmt(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), nextAfterAstRightmostLeaf(), none, op1_and_op2, Token::previous(), Settings::severity, Token::simpleMatch(), Tokenizer::tokens(), Token::tokType(), visitAstNodes(), and warning.
Referenced by runChecks().
|
private |
Definition at line 1051 of file checkother.cpp.
References Scope::bodyStart, ValueType::container, Variable::declarationId(), Scope::eDo, Scope::eSwitch, Scope::eUnconditional, Token::exprId(), findExpression(), Token::findExpressionStartEndTokens(), Token::findmatch(), Token::findsimplematch(), getTokenArgumentFunction(), Variable::isArray(), Variable::isArrayOrPointer(), Variable::isInit(), Scope::isLoopScope(), Token::isName(), Variable::isPointer(), Token::isSimplifiedScope(), Settings::library, Token::link(), Token::linkAt(), Token::Match(), Check::mSettings, Variable::nameToken(), Scope::nestedList, Token::next(), Token::previous(), Function::returnsPointer(), Library::returnValueType(), Token::scope(), Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), Scope::type, Variable::valueType(), and Token::varId().
Referenced by checkVariableScope().
|
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().
|
private |
Check for free() operations on invalid memory locations
Definition at line 2280 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Token::findmatch(), SymbolDatabase::functionScopes, Library::getAllocFuncInfo(), Library::getDeallocFuncInfo(), Tokenizer::getSymbolDatabase(), inconclusive, invalidFreeError(), SimpleEnableGroup< T >::isEnabled(), Library::isFunctionConst(), Settings::library, Token::linkAt(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), and Token::varId().
Referenced by runChecks().
|
private |
Definition at line 3652 of file checkother.cpp.
References astIsIntegral(), astIsPointer(), Token::astOperand2(), Token::astSibling(), Scope::bodyEnd, Scope::bodyStart, Token::expressionString(), findAstNode(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), getTokenArgumentFunction(), Token::hasKnownIntValue(), Token::isCast(), isConstVarExpression(), isCPPCast(), SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), isSameExpression(), isVariableExpression(), isVariableExprHidden(), knownArgumentError(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), none, op1_and_op2, Settings::severity, Token::str(), strTolower(), style, Token::values(), and visitAstNodes().
Referenced by runChecks().
|
private |
Definition at line 3753 of file checkother.cpp.
References astIsPointer(), Scope::bodyEnd, Scope::bodyStart, findParent(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Token::isExpandedMacro(), Settings::isPremiumEnabled(), isUsedAsBool(), knownPointerToBoolError(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, and style.
Referenced by runChecks().
|
private |
Check for objects that are destroyed immediately
Definition at line 2082 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, Library::check, Library::checkFiniteLifetime, Library::detectContainerOrIterator(), Token::function(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), Library::getTypeCheck(), Token::isAssignmentOp(), Tokenizer::isC(), isConstStatement(), SimpleEnableGroup< T >::isEnabled(), Token::isKeyword(), Settings::isPremiumEnabled(), Token::isStandardType(), Settings::library, Token::link(), Token::linkAt(), Check::logChecker(), Token::Match(), misusedScopeObjectError(), Check::mSettings, Check::mTokenizer, Token::next(), nextAfterAstRightmostLeaf(), Token::previous(), Function::returnsReference(), Settings::severity, Token::simpleMatch(), Token::str(), style, Token::tokAt(), Token::type(), and Token::varId().
Referenced by runChecks().
|
private |
Definition at line 3853 of file checkother.cpp.
References checkModuloOfOneError(), SimpleEnableGroup< T >::isEnabled(), ValueFlow::Value::isKnown(), Settings::isPremiumEnabled(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, style, and Tokenizer::tokens().
Referenced by runChecks().
|
private |
Definition at line 3875 of file checkother.cpp.
References Check::reportError(), and style.
Referenced by checkModuloOfOne(), and getErrorMessages().
|
private |
Check for NaN (not-a-number) in an arithmetic expression.
Definition at line 2056 of file checkother.cpp.
References SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, nanInArithmeticExpressionError(), Token::next(), Settings::severity, Token::simpleMatch(), style, and Tokenizer::tokens().
Referenced by runChecks().
|
private |
Check for bitwise shift with negative right operand
Definition at line 2923 of file checkother.cpp.
References Token::astParent(), SimpleEnableGroup< T >::isEnabled(), ValueType::isIntegral(), isNegative(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, negativeBitwiseShiftError(), Token::next(), portability, Settings::severity, and Tokenizer::tokens().
Referenced by runChecks().
|
private |
Definition at line 3941 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, Library::NonOverlappingData::countArg, SymbolDatabase::functionScopes, getArguments(), getBufAndOffset(), Token::getKnownIntValue(), Library::getNonOverlappingData(), Tokenizer::getSymbolDatabase(), Token::hasKnownIntValue(), Token::isBinaryOp(), isSameExpression(), Settings::library, Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), overlappingWriteFunction(), overlappingWriteUnion(), Library::NonOverlappingData::ptr1Arg, Library::NonOverlappingData::ptr2Arg, Token::simpleMatch(), Library::NonOverlappingData::sizeArg, Scope::type, Variable::typeScope(), and visitAstNodes().
Referenced by runChecks().
|
private |
Check for function parameters that should be passed by reference
Definition at line 1220 of file checkother.cpp.
References astIsRangeBasedForDecl(), Settings::certainty, ValueFlow::getSizeOf(), Tokenizer::getSymbolDatabase(), inconclusive, Tokenizer::isC(), SimpleEnableGroup< T >::isEnabled(), Token::isExternC(), isVariableChanged(), Check::logChecker(), Check::mSettings, Check::mTokenizer, passedByValueError(), performance, Settings::platform, Settings::severity, Platform::sizeof_pointer, and SymbolDatabase::variableList().
Referenced by runChecks().
|
private |
copying to memory or assigning to a variable twice
Definition at line 425 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Token::eIncDecOp, Token::findExpressionStartEndTokens(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), FwdAnalysis::hasOperand(), inconclusive, SimpleEnableGroup< T >::isEnabled(), isNullOperand(), MathLib::isNullValue(), Settings::isPremiumEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), FwdAnalysis::reassign(), redundantAssignmentError(), redundantAssignmentInSwitchError(), redundantInitializationError(), Settings::severity, Token::simpleMatch(), ValueType::SMART_POINTER, Token::str(), style, and visitAstNodes().
Referenced by runChecks().
|
private |
Check for code creating redundant copies
Definition at line 2844 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Settings::certainty, constructorTakesReference(), exprDependsOnThis(), Token::function(), Function::functionScope, ValueFlow::getSizeOf(), Tokenizer::getSymbolDatabase(), inconclusive, Tokenizer::isC(), SimpleEnableGroup< T >::isEnabled(), Token::isSplittedVarDeclEq(), isTemporary(), isVariableChanged(), Settings::library, Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), performance, Settings::platform, Token::previous(), redundantCopyError(), Settings::severity, Token::simpleMatch(), Platform::sizeof_pointer, Token::str(), Token::strAt(), Token::tokAt(), Function::tokenDef, Token::variable(), and SymbolDatabase::variableList().
Referenced by runChecks().
|
private |
Check for redundant pointer operations
Definition at line 3128 of file checkother.cpp.
References Token::astOperand1(), SimpleEnableGroup< T >::isEnabled(), Token::isExpandedMacro(), Variable::isPointer(), Settings::isPremiumEnabled(), Check::logChecker(), LValue, Check::mSettings, Check::mTokenizer, Variable::name(), Token::next(), ValueType::pointer, redundantPointerOpError(), ValueType::reference, Settings::severity, style, Tokenizer::tokens(), Token::valueType(), and Token::variable().
Referenced by runChecks().
|
private |
Check for shadow variables.
Less noisy than gcc/clang -Wshadow.
Definition at line 3571 of file checkother.cpp.
References Function::argumentList, Scope::className, Scope::eFunction, Scope::eLambda, findShadowed(), Scope::function, Scope::functionOf, Tokenizer::getSymbolDatabase(), Scope::isClassOrStructOrUnion(), SimpleEnableGroup< T >::isEnabled(), Scope::isExecutable(), Token::isExpandedMacro(), Settings::isPremiumEnabled(), Function::isStatic(), Token::linenr(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Variable::name(), Variable::nameToken(), Scope::nestedIn, SymbolDatabase::scopeList, Settings::severity, shadowError(), style, Scope::type, Token::variable(), Token::varId(), and Scope::varlist.
Referenced by runChecks().
|
private |
Check for testing sign of unsigned variable
Definition at line 2717 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, comparisonNonZeroExpressionLessThanZero(), Token::expressionString(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Token::next(), ValueType::pointer, pointerLessThanZeroError(), pointerPositiveError(), Settings::severity, style, testIfNonZeroExpressionIsPositive(), unsignedLessThanZeroError(), unsignedPositiveError(), and Token::valueType().
Referenced by runChecks().
|
private |
Check for code like 'case A||B:'
Definition at line 725 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Settings::certainty, Scope::eSwitch, Tokenizer::getSymbolDatabase(), inconclusive, SimpleEnableGroup< T >::isEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), SymbolDatabase::scopeList, Settings::severity, Token::str(), suspiciousCaseInSwitchError(), Scope::type, and warning.
Referenced by runChecks().
|
private |
Check for suspicious use of semicolon
Definition at line 261 of file checkother.cpp.
References Scope::bodyStart, Settings::certainty, Scope::classDef, Scope::eElse, Scope::eFor, Scope::eIf, Scope::eWhile, Tokenizer::getSymbolDatabase(), inconclusive, SimpleEnableGroup< T >::isEnabled(), Token::isExpandedMacro(), Token::linenr(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Token::previous(), SymbolDatabase::scopeList, Settings::severity, Token::simpleMatch(), suspiciousSemicolonError(), Token::tokAt(), Scope::type, and warning.
Referenced by runChecks().
|
private |
Check for code that gets never executed, such as duplicate break statements
Definition at line 772 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Settings::certainty, duplicateBreakError(), Scope::eSwitch, Token::findmatch(), Token::findsimplematch(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), inconclusive, SimpleEnableGroup< T >::isEnabled(), Token::isKeyword(), Library::isnoreturn(), Settings::isPremiumEnabled(), Settings::library, Token::linenr(), Token::link(), Token::linkAt(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Token::previous(), redundantContinueError(), Token::scope(), Settings::severity, Token::simpleMatch(), Token::str(), Token::strAt(), style, Token::tokAt(), and unreachableCodeError().
Referenced by runChecks().
|
private |
Check for unused labels
Definition at line 3220 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Scope::eSwitch, Token::findsimplematch(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), Tokenizer::hasIfdef(), SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Token::previous(), Settings::severity, style, unusedLabelError(), and warning.
Referenced by runChecks().
|
private |
Check that variadic function calls don't use NULL.
If NULL is #defined as 0 and the function expects a pointer, the behaviour is undefined.
Definition at line 3043 of file checkother.cpp.
References Function::argCount(), Function::argDef, Scope::bodyEnd, Scope::bodyStart, Token::function(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Token::isName(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), portability, Token::previous(), Settings::severity, Token::simpleMatch(), Token::str(), Token::tokAt(), and varFuncNullUBError().
Referenced by runChecks().
|
private |
Check scope of variables
Definition at line 937 of file checkother.cpp.
References astIsContainer(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), checkInnerScope(), Settings::clang, Settings::daca, Tokenizer::getSymbolDatabase(), Tokenizer::hasIfdef(), Tokenizer::isC(), SimpleEnableGroup< T >::isEnabled(), Token::isExpandedMacro(), Settings::isPremiumEnabled(), isSimpleExpr(), isWithinScope(), Token::link(), Token::linkAt(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Variable::nameToken(), Token::next(), Token::previous(), Token::scope(), Settings::severity, Token::simpleMatch(), Token::str(), style, Token::tokAt(), Token::variable(), SymbolDatabase::variableList(), variableScopeError(), and Token::varId().
Referenced by runChecks().
|
private |
Check zero division
Definition at line 2006 of file checkother.cpp.
References Scope::eEnum, Settings::isEnabled(), Check::logChecker(), Check::mSettings, Check::mTokenizer, Token::next(), Tokenizer::tokens(), and zerodivError().
Referenced by runChecks().
|
private |
Clarify calculation for ".. a * b ? ..".
Definition at line 154 of file checkother.cpp.
References Token::astOperand1(), Scope::bodyEnd, Scope::bodyStart, clarifyCalculationError(), Token::eBitOp, SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), ValueType::isEnum(), Token::isNumber(), Settings::isPremiumEnabled(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Settings::severity, Token::str(), style, and Token::valueType().
Referenced by runChecks().
|
private |
Definition at line 203 of file checkother.cpp.
References CWE783, normal, Check::reportError(), and style.
Referenced by clarifyCalculation(), and getErrorMessages().
|
private |
Suspicious statement like '*A++;'.
Definition at line 225 of file checkother.cpp.
References Token::astOperand1(), Token::astParent(), Scope::bodyEnd, Scope::bodyStart, clarifyStatementError(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Token::previous(), Settings::severity, Token::str(), and warning.
Referenced by runChecks().
|
private |
Definition at line 251 of file checkother.cpp.
References CWE783, normal, Check::reportError(), and warning.
Referenced by clarifyStatement(), and getErrorMessages().
|
inlineoverrideprivatevirtual |
get information about this class, used to generate documentation
Implements Check.
Definition at line 371 of file checkother.h.
|
private |
Definition at line 1203 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by checkCommaSeparatedReturn(), and getErrorMessages().
|
private |
Definition at line 3833 of file checkother.cpp.
References CWE570, error, ValueFlow::Value::errorPath, normal, Check::reportError(), Token::simpleMatch(), ValueFlow::Value::tokvalue, and Token::variable().
Referenced by checkComparePointers(), and getErrorMessages().
|
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().
|
private |
Definition at line 1957 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), CWE398, debug, Settings::debugwarnings, Token::eChar, Token::expressionString(), inconclusive, Token::isBoolean(), Token::isCast(), isConstant(), Token::isEnumerator(), isNullOperand(), Token::isNumber(), Token::Match(), Check::mSettings, normal, Check::reportError(), Token::simpleMatch(), Token::str(), Token::tokType(), and warning.
Referenced by checkIncompleteStatement(), and getErrorMessages().
Definition at line 1623 of file checkother.cpp.
References CWE398, Variable::isArgument(), Variable::isArray(), Variable::isPointer(), Variable::isReference(), Variable::name(), Variable::nameToken(), normal, Check::reportError(), and style.
Referenced by checkConstPointer(), checkConstVariable(), and getErrorMessages().
|
private |
Definition at line 357 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by getErrorMessages(), and warningOldStylePointerCast().
|
private |
Definition at line 2626 of file checkother.cpp.
References CWE398, inconclusive, normal, Check::reportError(), Token::str(), and style.
Referenced by checkDuplicateExpression(), and getErrorMessages().
|
private |
Definition at line 2263 of file checkother.cpp.
References CWE398, inconclusive, Check::reportError(), and style.
Referenced by checkDuplicateBranch(), and getErrorMessages().
|
private |
Definition at line 881 of file checkother.cpp.
References CWE561, inconclusive, normal, Check::reportError(), and style.
Referenced by checkUnreachableCode(), and getErrorMessages().
|
private |
Definition at line 2598 of file checkother.cpp.
References CWE398, Token::expressionString(), Token::Match(), normal, Check::reportError(), Token::str(), and style.
Referenced by checkDuplicateExpression(), and getErrorMessages().
Definition at line 2640 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by checkDuplicateExpression(), and getErrorMessages().
|
private |
Definition at line 2648 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by checkDuplicateExpression(), and getErrorMessages().
|
private |
Definition at line 3509 of file checkother.cpp.
References CWE628, inconclusive, Check::reportError(), Token::str(), and style.
Referenced by checkFuncArgNamesDifferent(), and getErrorMessages().
|
private |
Definition at line 3520 of file checkother.cpp.
References CWE683, normal, Check::reportError(), Token::str(), and warning.
Referenced by checkFuncArgNamesDifferent(), and getErrorMessages().
|
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().
|
private |
Definition at line 3023 of file checkother.cpp.
References CWE131, inconclusive, portability, Check::reportError(), and warning.
Referenced by checkIncompleteArrayFill(), and getErrorMessages().
|
private |
Definition at line 2354 of file checkother.cpp.
References CWE, error, inconclusive, normal, and Check::reportError().
Referenced by checkInvalidFree(), and getErrorMessages().
|
private |
Check for pointer casts to a type with an incompatible binary data representation.
Definition at line 372 of file checkother.cpp.
References Token::astOperand1(), Token::astOperand2(), Scope::bodyEnd, Scope::bodyStart, Settings::certainty, SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), inconclusive, invalidPointerCastError(), SimpleEnableGroup< T >::isEnabled(), ValueType::isIntegral(), Token::linkAt(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), ValueType::pointer, portability, Settings::severity, Token::simpleMatch(), ValueType::str(), ValueType::type, and Token::valueType().
Referenced by runChecks().
|
private |
Definition at line 412 of file checkother.cpp.
References CWE704, inconclusive, normal, portability, and Check::reportError().
Referenced by getErrorMessages(), and invalidPointerCast().
|
private |
Definition at line 3721 of file checkother.cpp.
References CWE570, Token::expressionString(), Check::getErrorPath(), ValueFlow::Value::intvalue, normal, Check::reportError(), Token::str(), style, and Token::type().
Referenced by checkKnownArgument(), and getErrorMessages().
|
private |
Definition at line 3783 of file checkother.cpp.
References bool_to_string(), CWE570, Token::expressionString(), Check::getErrorPath(), ValueFlow::Value::intvalue, normal, Check::reportError(), and style.
Referenced by checkKnownPointerToBool(), and getErrorMessages().
|
private |
Definition at line 2157 of file checkother.cpp.
References CWE563, normal, Check::reportError(), and style.
Referenced by checkMisusedScopedObject(), and getErrorMessages().
|
inlinestaticprivate |
Definition at line 367 of file checkother.h.
|
private |
Definition at line 2071 of file checkother.cpp.
References CWE369, normal, Check::reportError(), and style.
Referenced by checkNanInArithmeticExpression(), and getErrorMessages().
|
private |
Definition at line 2963 of file checkother.cpp.
References CWE758, error, normal, portability, and Check::reportError().
Referenced by checkNegativeBitwiseShift(), and getErrorMessages().
Definition at line 2586 of file checkother.cpp.
References CWE398, normal, Check::reportError(), Token::str(), and style.
Referenced by checkDuplicateExpression(), and getErrorMessages().
|
private |
Definition at line 4044 of file checkother.cpp.
References emptyString, error, Check::reportError(), and Token::str().
Referenced by checkOverlappingWrite(), and getErrorMessages().
|
private |
Definition at line 4039 of file checkother.cpp.
References error, and Check::reportError().
Referenced by checkOverlappingWrite(), and getErrorMessages().
|
private |
Definition at line 1279 of file checkother.cpp.
References CWE398, Scope::function, Function::functionPointerUsage, inconclusive, Variable::name(), Function::name(), Variable::nameToken(), normal, performance, Check::reportError(), and Variable::scope().
Referenced by checkPassByReference(), and getErrorMessages().
|
private |
Definition at line 2805 of file checkother.cpp.
References CWE570, Check::getErrorPath(), normal, Check::reportError(), and style.
Referenced by checkSignOfUnsignedVariable(), and getErrorMessages().
|
private |
Definition at line 2818 of file checkother.cpp.
References CWE570, Check::getErrorPath(), normal, Check::reportError(), and style.
Referenced by checkSignOfUnsignedVariable(), and getErrorMessages().
|
private |
Definition at line 3214 of file checkother.cpp.
References CWE362, error, normal, and Check::reportError().
Referenced by checkInterlockedDecrement(), and getErrorMessages().
|
private |
Definition at line 550 of file checkother.cpp.
References CWE563, inconclusive, normal, Check::reportError(), and style.
Referenced by checkRedundantAssignment(), and getErrorMessages().
|
private |
Definition at line 573 of file checkother.cpp.
References CWE563, normal, Check::reportError(), and style.
Referenced by checkRedundantAssignment(), and getErrorMessages().
|
private |
Check for redundant bitwise operation in switch statement
Definition at line 596 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Scope::eSwitch, Tokenizer::getSymbolDatabase(), SimpleEnableGroup< T >::isEnabled(), isFunctionOrBreakPattern(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), SymbolDatabase::scopeList, Settings::severity, Token::strAt(), Scope::type, and warning.
Referenced by getErrorMessages(), and runChecks().
|
private |
Definition at line 713 of file checkother.cpp.
References Check::reportError(), and style.
|
private |
Definition at line 903 of file checkother.cpp.
References CWE561, normal, Check::reportError(), and style.
Referenced by checkUnreachableCode().
|
private |
Definition at line 2903 of file checkother.cpp.
References CWE398, inconclusive, performance, and Check::reportError().
|
private |
Definition at line 542 of file checkother.cpp.
References CWE563, normal, performance, and Check::reportError().
Referenced by checkRedundantCopy(), and getErrorMessages().
|
private |
Definition at line 564 of file checkother.cpp.
References CWE563, inconclusive, normal, Check::reportError(), and style.
Referenced by checkRedundantAssignment(), and getErrorMessages().
|
private |
Definition at line 3167 of file checkother.cpp.
References CWE398, inconclusive, normal, Check::reportError(), and style.
Referenced by checkRedundantPointerOp(), and getErrorMessages().
|
inlineoverrideprivatevirtual |
Run checks against the normal token list.
Implements Check.
Definition at line 71 of file checkother.h.
References checkAccessOfMovedVariable(), checkCastIntToCharAndBack(), checkCharVariable(), checkCommaSeparatedReturn(), checkComparePointers(), checkComparisonFunctionIsAlwaysTrueOrFalse(), checkConstPointer(), checkConstVariable(), checkDuplicateBranch(), checkDuplicateExpression(), checkEvaluationOrder(), checkFuncArgNamesDifferent(), checkIncompleteArrayFill(), checkIncompleteStatement(), checkInterlockedDecrement(), checkInvalidFree(), checkKnownArgument(), checkKnownPointerToBool(), checkMisusedScopedObject(), checkModuloOfOne(), checkNanInArithmeticExpression(), checkNegativeBitwiseShift(), checkOverlappingWrite(), checkPassByReference(), checkRedundantAssignment(), checkRedundantCopy(), checkRedundantPointerOp(), checkShadowVariables(), checkSignOfUnsignedVariable(), checkSuspiciousCaseInSwitch(), checkSuspiciousSemicolon(), checkUnreachableCode(), checkUnusedLabel(), checkVarFuncNullUB(), checkVariableScope(), checkZeroDivision(), clarifyCalculation(), clarifyStatement(), Tokenizer::getSettings(), invalidPointerCast(), redundantBitwiseOperationInSwitchError(), and warningOldStylePointerCast().
|
private |
Definition at line 2655 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by checkDuplicateExpression(), checkEvaluationOrder(), and getErrorMessages().
|
private |
Definition at line 3613 of file checkother.cpp.
References CWE398, normal, Check::reportError(), Token::str(), and style.
Referenced by checkShadowVariables(), and getErrorMessages().
|
private |
Definition at line 1712 of file checkother.cpp.
References CWE128, normal, Check::reportError(), and warning.
Referenced by checkCharVariable(), and getErrorMessages().
|
private |
Definition at line 759 of file checkother.cpp.
References CWE398, inconclusive, Check::reportError(), and warning.
Referenced by checkSuspiciousCaseInSwitch(), and getErrorMessages().
|
private |
Definition at line 285 of file checkother.cpp.
References CWE398, normal, Check::reportError(), Token::str(), and warning.
Referenced by checkSuspiciousSemicolon(), and getErrorMessages().
|
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().
|
private |
Definition at line 3344 of file checkother.cpp.
References CWE768, error, Token::expressionString(), normal, and Check::reportError().
Referenced by checkEvaluationOrder(), and getErrorMessages().
|
private |
Definition at line 1723 of file checkother.cpp.
References CWE758, normal, portability, and Check::reportError().
Referenced by checkCharVariable(), and getErrorMessages().
|
private |
Definition at line 889 of file checkother.cpp.
References CWE561, Token::function(), inconclusive, Token::isKeyword(), Library::isnoreturn(), Settings::library, Check::mSettings, normal, Check::reportError(), Token::str(), and style.
Referenced by checkUnreachableCode(), and getErrorMessages().
|
private |
Definition at line 2796 of file checkother.cpp.
References CWE570, Check::getErrorPath(), normal, Check::reportError(), and style.
Referenced by checkSignOfUnsignedVariable(), and getErrorMessages().
|
private |
Definition at line 2811 of file checkother.cpp.
References CWE570, Check::getErrorPath(), normal, Check::reportError(), and style.
Referenced by checkSignOfUnsignedVariable(), and getErrorMessages().
|
private |
Definition at line 3243 of file checkother.cpp.
References CWE398, emptyString, SimpleEnableGroup< T >::isEnabled(), Check::mSettings, normal, Check::reportError(), Settings::severity, Token::str(), style, and warning.
Referenced by checkUnusedLabel(), and getErrorMessages().
|
private |
Definition at line 3081 of file checkother.cpp.
References CWE475, normal, portability, and Check::reportError().
Referenced by checkVarFuncNullUB(), and getErrorMessages().
|
private |
Definition at line 1149 of file checkother.cpp.
References CWE398, normal, Check::reportError(), and style.
Referenced by checkVariableScope(), and getErrorMessages().
|
private |
Are there C-style pointer casts in a c++ file?
Definition at line 295 of file checkother.cpp.
References Scope::bodyEnd, Scope::bodyStart, Scope::classDef, cstyleCastError(), Token::eName, Token::eType, Scope::function, SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), Token::hasKnownIntValue(), Function::isConstructor(), Tokenizer::isCPP(), SimpleEnableGroup< T >::isEnabled(), Settings::isPremiumEnabled(), Token::link(), Check::logChecker(), Token::Match(), Check::mSettings, Check::mTokenizer, Token::next(), Token::previous(), Settings::severity, Token::simpleMatch(), Token::str(), Token::strAt(), style, Token::tokAt(), Token::tokType(), and Token::values().
Referenced by runChecks().
|
private |
Definition at line 2027 of file checkother.cpp.
References ValueFlow::Value::condition, CWE369, ValueFlow::eitherTheConditionIsRedundant(), error, ValueFlow::Value::errorSeverity(), Check::getErrorPath(), inconclusive, ValueFlow::Value::isInconclusive(), Token::linenr(), normal, Check::reportError(), Token::str(), and warning.
Referenced by checkZeroDivision(), and getErrorMessages().
|
friend |
Definition at line 50 of file checkother.h.
|
friend |
Definition at line 51 of file checkother.h.
|
friend |
Definition at line 52 of file checkother.h.