49         : 
Check(myName(), tokenizer, settings, errorLogger) {}
 
   69     void checkComparisonOfFuncReturningBool();
 
   72     void checkComparisonOfBoolWithBool();
 
   75     void checkIncrementBoolean();
 
   78     void checkComparisonOfBoolWithInt();
 
   81     void checkAssignBoolToPointer();
 
   84     void checkAssignBoolToFloat();
 
   87     void checkBitwiseOnBoolean();
 
   90     void checkComparisonOfBoolExpressionWithInt();
 
   93     void pointerArithBool();
 
   94     void pointerArithBoolCond(
const Token *tok);
 
   97     void returnValueOfFunctionReturningBool();
 
  100     void comparisonOfFuncReturningBoolError(
const Token *tok, 
const std::string &expression);
 
  101     void comparisonOfTwoFuncsReturningBoolError(
const Token *tok, 
const std::string &expression1, 
const std::string &expression2);
 
  102     void comparisonOfBoolWithBoolError(
const Token *tok, 
const std::string &expression);
 
  103     void incrementBooleanError(
const Token *tok);
 
  104     void comparisonOfBoolWithInvalidComparator(
const Token *tok, 
const std::string &expression);
 
  105     void assignBoolToPointerError(
const Token *tok);
 
  106     void assignBoolToFloatError(
const Token *tok);
 
  107     void bitwiseOnBooleanError(
const Token* tok, 
const std::string& expression, 
const std::string& op, 
bool isCompound = 
false);
 
  108     void comparisonOfBoolExpressionWithIntError(
const Token *tok, 
bool not0or1);
 
  109     void pointerArithBoolError(
const Token *tok);
 
  110     void returnValueBoolError(
const Token *tok);
 
  113         CheckBool c(
nullptr, settings, errorLogger);
 
  132         return "Boolean type checks\n" 
  133                "- using increment on boolean\n" 
  134                "- comparison of a boolean expression with an integer other than 0 or 1\n" 
  135                "- comparison of a function returning boolean value using relational operator\n" 
  136                "- comparison of a boolean value with boolean value using relational operator\n" 
  137                "- using bool in bitwise expression\n" 
  138                "- pointer addition in condition (either dereference is forgot or pointer overflow is required to make the condition false)\n" 
  139                "- Assigning bool value to pointer or float\n" 
  140                "- Returning an integer other than 0 or 1 from a function with boolean return value\n";
 
checks dealing with suspicious usage of boolean type (not for evaluating conditions)
 
CheckBool()
This constructor is used when registering the CheckClass.
 
void assignBoolToPointerError(const Token *tok)
 
void checkBitwiseOnBoolean()
Check for using bool in bitwise expression
 
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
 
static std::string myName()
 
void pointerArithBoolError(const Token *tok)
 
CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
 
std::string classInfo() const override
get information about this class, used to generate documentation
 
void comparisonOfFuncReturningBoolError(const Token *tok, const std::string &expression)
 
void pointerArithBool()
Check for 'if (p+1)' etc.
 
void checkComparisonOfBoolWithBool()
Check for comparison of variable of type bool
 
void incrementBooleanError(const Token *tok)
 
void checkComparisonOfBoolWithInt()
Check for suspicious comparison of a bool and a non-zero (and non-one) value (e.g.
 
void comparisonOfBoolWithBoolError(const Token *tok, const std::string &expression)
 
void checkAssignBoolToPointer()
assigning bool to pointer
 
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
Run checks against the normal token list.
 
void comparisonOfBoolExpressionWithIntError(const Token *tok, bool not0or1)
 
void bitwiseOnBooleanError(const Token *tok, const std::string &expression, const std::string &op, bool isCompound=false)
 
void returnValueBoolError(const Token *tok)
 
void checkComparisonOfFuncReturningBool()
Check for comparison of function returning bool
 
void comparisonOfBoolWithInvalidComparator(const Token *tok, const std::string &expression)
 
void checkComparisonOfBoolExpressionWithInt()
Check for comparing a bool expression with an integer other than 0 or 1
 
void checkIncrementBoolean()
Check for using postfix increment on bool
 
void returnValueOfFunctionReturningBool()
Check if a function returning bool returns an integer other than 0 or 1
 
void assignBoolToFloatError(const Token *tok)
 
void comparisonOfTwoFuncsReturningBoolError(const Token *tok, const std::string &expression1, const std::string &expression2)
 
void checkAssignBoolToFloat()
assigning bool to float
 
Interface class that cppcheck uses to communicate with the checks.
 
This is an interface, which the class responsible of error logging should implement.
 
This is just a container for general settings so that we don't need to pass individual values to func...
 
The token list that the TokenList generates is a linked-list of this class.
 
The main purpose is to tokenize the source code.
 
const Settings & getSettings() const