| 
    Cppcheck
    
   | 
 
Checking for side effects in assert statements. More...
#include <checkassert.h>
  
Public Member Functions | |
| CheckAssert () | |
  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 &) | 
Private Member Functions | |
| CheckAssert (const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) | |
| void | runChecks (const Tokenizer &tokenizer, ErrorLogger *errorLogger) override | 
| run checks, the token list is not simplified  More... | |
| void | assertWithSideEffects () | 
| void | checkVariableAssignment (const Token *assignTok, const Scope *assertionScope) | 
| void | sideEffectInAssertError (const Token *tok, const std::string &functionName) | 
| void | assignmentInAssertError (const Token *tok, const std::string &varname) | 
| 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 bool | inSameScope (const Token *returnTok, const Token *assignTok) | 
| static std::string | myName () | 
Additional Inherited Members | |
  Static Public Member Functions inherited from Check | |
| static std::list< Check * > & | instances () | 
| List of registered check classes.  More... | |
| static void | writeToErrorList (const ErrorMessage &errmsg) | 
| Write given error to stdout in xml format.  More... | |
  Protected Member Functions inherited from Check | |
| Check (std::string aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) | |
| This constructor is used when running checks.  More... | |
| void | reportError (const Token *tok, const Severity severity, const std::string &id, const std::string &msg) | 
| report an error  More... | |
| void | reportError (const Token *tok, const Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty) | 
| report an error  More... | |
| void | reportError (const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg) | 
| report an error  More... | |
| void | reportError (const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty) | 
| report an error  More... | |
| void | reportError (const ErrorPath &errorPath, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty) | 
| void | logChecker (const char id[]) | 
| log checker  More... | |
| ErrorPath | getErrorPath (const Token *errtok, const ValueFlow::Value *value, std::string bug) const | 
| bool | wrongData (const Token *tok, const char *str) | 
| Use WRONG_DATA in checkers when you check for wrong data.  More... | |
  Static Protected Member Functions inherited from Check | |
| static std::string | getMessageId (const ValueFlow::Value &value, const char id[]) | 
  Protected Attributes inherited from Check | |
| const Tokenizer *const | mTokenizer {} | 
| const Settings *const | mSettings {} | 
| ErrorLogger *const | mErrorLogger {} | 
Checking for side effects in assert statements.
Definition at line 43 of file checkassert.h.
      
  | 
  inline | 
Definition at line 45 of file checkassert.h.
      
  | 
  inlineprivate | 
Definition at line 48 of file checkassert.h.
      
  | 
  private | 
Definition at line 43 of file checkassert.cpp.
References astIsSmartPointer(), Scope::bodyEnd, Scope::bodyStart, checkVariableAssignment(), Token::eFunction, Token::eIncDecOp, Library::Container::END_ITERATOR, TokenList::front(), Function::functionScope, Library::getContainerYield(), Library::getFunction(), Library::getFunctionName(), inSameScope(), Variable::isArgument(), Scope::isClassOrStruct(), Function::isConst(), SimpleEnableGroup< T >::isEnabled(), Variable::isLocal(), Variable::isPointer(), Variable::isReference(), Function::isStatic(), Library::Container::ITERATOR, Settings::library, Token::link(), Tokenizer::list, Check::logChecker(), Check::mSettings, Check::mTokenizer, Function::name(), Function::nestedIn, Token::next(), Library::Container::NO_YIELD, Settings::severity, sideEffectInAssertError(), Token::simpleMatch(), Library::Container::START_ITERATOR, and warning.
Referenced by runChecks().
      
  | 
  private | 
Definition at line 133 of file checkassert.cpp.
References CWE398, normal, Check::reportError(), and warning.
Referenced by checkVariableAssignment(), and getErrorMessages().
      
  | 
  private | 
Definition at line 146 of file checkassert.cpp.
References assignmentInAssertError(), Token::astOperand1(), Token::eIncDecOp, Token::isAssignmentOp(), Variable::isConst(), Variable::name(), Scope::nestedIn, Variable::scope(), and Token::tokType().
Referenced by assertWithSideEffects().
      
  | 
  inlineoverrideprivatevirtual | 
get information about this class, used to generate documentation
Implements Check.
Definition at line 75 of file checkassert.h.
      
  | 
  inlineoverrideprivatevirtual | 
get error messages
Implements Check.
Definition at line 65 of file checkassert.h.
References assignmentInAssertError(), and sideEffectInAssertError().
Definition at line 174 of file checkassert.cpp.
References Token::scope().
Referenced by assertWithSideEffects().
      
  | 
  inlinestaticprivate | 
Definition at line 71 of file checkassert.h.
      
  | 
  inlineoverrideprivatevirtual | 
run checks, the token list is not simplified
Implements Check.
Definition at line 52 of file checkassert.h.
References assertWithSideEffects(), and Tokenizer::getSettings().
      
  | 
  private | 
Definition at line 121 of file checkassert.cpp.
References CWE398, normal, Check::reportError(), and warning.
Referenced by assertWithSideEffects(), and getErrorMessages().