"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/checkbool.h" between
cppcheck-1.86.tar.gz and cppcheck-1.87.tar.gz

About: Cppcheck is a static analysis tool for C/C++ code. It checks for memory leaks, mismatching allocation-deallocation, buffer overrun, and many more.

checkbool.h  (cppcheck-1.86):checkbool.h  (cppcheck-1.87)
/* /*
* Cppcheck - A tool for static C/C++ code analysis * Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2018 Cppcheck team. * Copyright (C) 2007-2019 Cppcheck team.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 51 skipping to change at line 51
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckBool() : Check(myName()) { CheckBool() : Check(myName()) {
} }
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLo gger *errorLogger) override { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLo gger *errorLogger) OVERRIDE {
CheckBool checkBool(tokenizer, settings, errorLogger); CheckBool checkBool(tokenizer, settings, errorLogger);
// Checks // Checks
checkBool.checkComparisonOfBoolExpressionWithInt(); checkBool.checkComparisonOfBoolExpressionWithInt();
checkBool.checkComparisonOfBoolWithInt(); checkBool.checkComparisonOfBoolWithInt();
checkBool.checkAssignBoolToFloat(); checkBool.checkAssignBoolToFloat();
checkBool.pointerArithBool(); checkBool.pointerArithBool();
checkBool.returnValueOfFunctionReturningBool(); checkBool.returnValueOfFunctionReturningBool();
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *setting s, ErrorLogger *errorLogger) override { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *setting s, ErrorLogger *errorLogger) OVERRIDE {
CheckBool checkBool(tokenizer, settings, errorLogger); CheckBool checkBool(tokenizer, settings, errorLogger);
// Checks // Checks
checkBool.checkComparisonOfFuncReturningBool(); checkBool.checkComparisonOfFuncReturningBool();
checkBool.checkComparisonOfBoolWithBool(); checkBool.checkComparisonOfBoolWithBool();
checkBool.checkIncrementBoolean(); checkBool.checkIncrementBoolean();
checkBool.checkAssignBoolToPointer(); checkBool.checkAssignBoolToPointer();
checkBool.checkBitwiseOnBoolean(); checkBool.checkBitwiseOnBoolean();
} }
skipping to change at line 119 skipping to change at line 119
void comparisonOfBoolWithBoolError(const Token *tok, const std::string &expr ession); void comparisonOfBoolWithBoolError(const Token *tok, const std::string &expr ession);
void incrementBooleanError(const Token *tok); void incrementBooleanError(const Token *tok);
void comparisonOfBoolWithInvalidComparator(const Token *tok, const std::stri ng &expression); void comparisonOfBoolWithInvalidComparator(const Token *tok, const std::stri ng &expression);
void assignBoolToPointerError(const Token *tok); void assignBoolToPointerError(const Token *tok);
void assignBoolToFloatError(const Token *tok); void assignBoolToFloatError(const Token *tok);
void bitwiseOnBooleanError(const Token *tok, const std::string &varname, con st std::string &op); void bitwiseOnBooleanError(const Token *tok, const std::string &varname, con st std::string &op);
void comparisonOfBoolExpressionWithIntError(const Token *tok, bool n0o1); void comparisonOfBoolExpressionWithIntError(const Token *tok, bool n0o1);
void pointerArithBoolError(const Token *tok); void pointerArithBoolError(const Token *tok);
void returnValueBoolError(const Token *tok); void returnValueBoolError(const Token *tok);
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) co nst override { void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) co nst OVERRIDE {
CheckBool c(nullptr, settings, errorLogger); CheckBool c(nullptr, settings, errorLogger);
c.assignBoolToPointerError(nullptr); c.assignBoolToPointerError(nullptr);
c.assignBoolToFloatError(nullptr); c.assignBoolToFloatError(nullptr);
c.comparisonOfFuncReturningBoolError(nullptr, "func_name"); c.comparisonOfFuncReturningBoolError(nullptr, "func_name");
c.comparisonOfTwoFuncsReturningBoolError(nullptr, "func_name1", "func_na me2"); c.comparisonOfTwoFuncsReturningBoolError(nullptr, "func_name1", "func_na me2");
c.comparisonOfBoolWithBoolError(nullptr, "var_name"); c.comparisonOfBoolWithBoolError(nullptr, "var_name");
c.incrementBooleanError(nullptr); c.incrementBooleanError(nullptr);
c.bitwiseOnBooleanError(nullptr, "varname", "&&"); c.bitwiseOnBooleanError(nullptr, "varname", "&&");
c.comparisonOfBoolExpressionWithIntError(nullptr, true); c.comparisonOfBoolExpressionWithIntError(nullptr, true);
c.pointerArithBoolError(nullptr); c.pointerArithBoolError(nullptr);
c.comparisonOfBoolWithInvalidComparator(nullptr, "expression"); c.comparisonOfBoolWithInvalidComparator(nullptr, "expression");
c.returnValueBoolError(nullptr); c.returnValueBoolError(nullptr);
} }
static std::string myName() { static std::string myName() {
return "Boolean"; return "Boolean";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "Boolean type checks\n" return "Boolean type checks\n"
"- using increment on boolean\n" "- using increment on boolean\n"
"- comparison of a boolean expression with an integer other than 0 or 1\n" "- comparison of a boolean expression with an integer other than 0 or 1\n"
"- comparison of a function returning boolean value using relatio nal operator\n" "- comparison of a function returning boolean value using relatio nal operator\n"
"- comparison of a boolean value with boolean value using relatio nal operator\n" "- comparison of a boolean value with boolean value using relatio nal operator\n"
"- using bool in bitwise expression\n" "- using bool in bitwise expression\n"
"- pointer addition in condition (either dereference is forgot or pointer overflow is required to make the condition false)\n" "- pointer addition in condition (either dereference is forgot or pointer overflow is required to make the condition false)\n"
"- Assigning bool value to pointer or float\n" "- Assigning bool value to pointer or float\n"
"- Returning an integer other than 0 or 1 from a function with bo olean return value\n"; "- Returning an integer other than 0 or 1 from a function with bo olean return value\n";
} }
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)