From 036fcf7827ee4a6d5e826c110caeb81e308c47ff Mon Sep 17 00:00:00 2001 From: rikardfalkeborn Date: Fri, 28 Dec 2018 12:59:05 +0100 Subject: [PATCH] Fix warnings (#1541) * Fix reorder warning * Fix override warnings Clang warns about missing overrides. * Remove unused function * Add missing argument to function calls --- lib/astutils.cpp | 6 +++--- lib/checkmemoryleak.cpp | 14 -------------- lib/checknullpointer.h | 4 ++-- lib/checkuninitvar.h | 6 +++--- lib/token.h | 4 ++-- lib/valueflow.cpp | 2 +- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index fcf6f2c5d..c28de7159 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -372,17 +372,17 @@ bool isSameExpression(bool cpp, bool macro, const Token *tok1, const Token *tok2 const Token * varTok1 = followVariableExpression(tok1, cpp, tok2); if (varTok1->str() == tok2->str()) { followVariableExpressionError(tok1, varTok1, errors); - return isSameExpression(cpp, macro, varTok1, tok2, library, true, errors); + return isSameExpression(cpp, macro, varTok1, tok2, library, true, followVar, errors); } const Token * varTok2 = followVariableExpression(tok2, cpp, tok1); if (tok1->str() == varTok2->str()) { followVariableExpressionError(tok2, varTok2, errors); - return isSameExpression(cpp, macro, tok1, varTok2, library, true, errors); + return isSameExpression(cpp, macro, tok1, varTok2, library, true, followVar, errors); } if (varTok1->str() == varTok2->str()) { followVariableExpressionError(tok1, varTok1, errors); followVariableExpressionError(tok2, varTok2, errors); - return isSameExpression(cpp, macro, varTok1, varTok2, library, true, errors); + return isSameExpression(cpp, macro, varTok1, varTok2, library, true, followVar, errors); } } if (tok1->varId() != tok2->varId() || tok1->str() != tok2->str() || tok1->originalName() != tok2->originalName()) { diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 8d05c462c..3f2a887fd 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -488,20 +488,6 @@ static bool ifvar(const Token *tok, unsigned int varid, const std::string &comp, return (vartok && vartok->varId() == varid); } -static bool alwaysTrue(const Token *tok) -{ - if (!tok) - return false; - if (tok->hasKnownIntValue() && - tok->values().front().intvalue != 0) - return true; - if (tok->str() == "||") - return alwaysTrue(tok->astOperand1()) || alwaysTrue(tok->astOperand2()); - if (tok->str() == "true") - return true; - return false; -} - bool CheckMemoryLeakInFunction::test_white_list(const std::string &funcname, const Settings *settings, bool cpp) { return ((call_func_white_list.find(funcname)!=call_func_white_list.end()) || settings->library.isLeakIgnore(funcname) || (cpp && funcname == "delete")); diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index d120c2877..66f1dd478 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -114,10 +114,10 @@ public: /** @brief Parse current TU and extract file info */ Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; - Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const; + Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override; /** @brief Analyse all file infos for all TU */ - bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list &fileInfo, const Settings& settings, ErrorLogger &errorLogger); + bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; private: /** Get error messages. Used by --errorlist */ diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index ad626be31..239a25483 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -100,12 +100,12 @@ public: }; /** @brief Parse current TU and extract file info */ - Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const; + Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override; - Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const; + Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override; /** @brief Analyse all file infos for all TU */ - bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list &fileInfo, const Settings& settings, ErrorLogger &errorLogger); + bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; void uninitstringError(const Token *tok, const std::string &varname, bool strncpy_); void uninitdataError(const Token *tok, const std::string &varname); diff --git a/lib/token.h b/lib/token.h index b74199390..f28eb93f2 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1034,10 +1034,10 @@ private: fAtAddress = (1 << 24), // @ 0x4000 }; - unsigned int mFlags; - Token::Type mTokType; + unsigned int mFlags; + TokenImpl *mImpl; /** diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index d2582e9d8..09b8d8057 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1158,7 +1158,7 @@ static void valueFlowSameExpressions(TokenList *tokenlist) if (!val.isKnown()) continue; - if (isSameExpression(tokenlist->isCPP(), false, tok->astOperand1(), tok->astOperand2(), tokenlist->getSettings()->library, true, &val.errorPath)) { + if (isSameExpression(tokenlist->isCPP(), false, tok->astOperand1(), tok->astOperand2(), tokenlist->getSettings()->library, true, true, &val.errorPath)) { setTokenValue(tok, val, tokenlist->getSettings()); } }