diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 9832d492c..5b21565c6 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -664,6 +664,10 @@ void CmdLineParser::PrintHelp() " Enable all checks\n" " * style\n" " Check coding style\n" + " * performance\n" + " Check for performance problems\n" + " * portability\n" + " Check for portability problems\n" " * information\n" " Enable information messages\n" " * unusedFunction\n" diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index a8e593ba7..840fd20ca 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -46,7 +46,7 @@ static bool isint(const Variable *var) void Check64BitPortability::pointerassignment() { - if (!_settings->isEnabled("style")) + if (!_settings->isEnabled("portability")) return; for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 4206a4ac2..aca212211 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1057,7 +1057,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vectorstrAt(3)); - if (index > size && _settings->isEnabled("style")) + if (index > size && _settings->isEnabled("portability")) pointerOutOfBoundsError(tok->next(), "buffer"); if (index >= size && Token::Match(tok->tokAt(-2), "[;{}] %varid% =", varid)) pointerIsOutOfBounds = true; @@ -1276,7 +1276,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo } // undefined behaviour: result of pointer arithmetic is out of bounds - if (_settings->isEnabled("style") && Token::Match(tok, "= %varid% + %num% ;", arrayInfo.varid())) + if (_settings->isEnabled("portability") && Token::Match(tok, "= %varid% + %num% ;", arrayInfo.varid())) { const MathLib::bigint index = MathLib::toLongNumber(tok->strAt(3)); if (index < 0 || index > arrayInfo.num(0)) diff --git a/lib/checknonreentrantfunctions.cpp b/lib/checknonreentrantfunctions.cpp index 67d729ef9..dc328e3b6 100644 --- a/lib/checknonreentrantfunctions.cpp +++ b/lib/checknonreentrantfunctions.cpp @@ -33,7 +33,7 @@ CheckNonReentrantFunctions instance; void CheckNonReentrantFunctions::nonReentrantFunctions() { - if (!_settings->posix || !_settings->isEnabled("style")) + if (!_settings->posix || !_settings->isEnabled("portability")) return; // Don't check C# and Java code diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 519e5cade..480cf1d20 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1576,7 +1576,7 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname //--------------------------------------------------------------------------- void CheckOther::checkConstantFunctionParameter() { - if (!_settings->isEnabled("style")) + if (!_settings->isEnabled("performance")) return; const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase(); @@ -2368,7 +2368,7 @@ void CheckOther::duplicateExpressionError(const Token *tok1, const Token *tok2, //--------------------------------------------------------------------------- void CheckOther::checkAlwaysTrueOrFalseStringCompare() { - if (!_settings->isEnabled("style")) + if (!_settings->isEnabled("style") && !_settings->isEnabled("performance")) return; const char pattern1[] = "strcmp|stricmp|strcmpi|strcasecmp|wcscmp ( %str% , %str% )"; @@ -2403,7 +2403,7 @@ void CheckOther::alwaysTrueFalseStringCompareError(const Token *tok, const std:: "If the purpose is to compare these two strings, the comparison is unnecessary. " "If the strings are supposed to be different, then there is a bug somewhere."); } - else + else if (_settings->isEnabled("performance")) { reportError(tok, Severity::performance, "staticStringCompare", "Unnecessary comparison of static strings.\n" diff --git a/lib/checkpostfixoperator.cpp b/lib/checkpostfixoperator.cpp index 84621e60d..272d71f02 100644 --- a/lib/checkpostfixoperator.cpp +++ b/lib/checkpostfixoperator.cpp @@ -35,7 +35,7 @@ CheckPostfixOperator instance; void CheckPostfixOperator::postfixOperator() { - if (!_settings->isEnabled("style")) + if (!_settings->isEnabled("performance")) return; const Token *tok = _tokenizer->tokens(); diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 81c8b3812..39cab32b2 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -848,7 +848,7 @@ bool CheckStl::isStlContainer(unsigned int varid) void CheckStl::size() { - if (!_settings->isEnabled("style")) + if (!_settings->isEnabled("performance")) return; for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) diff --git a/lib/settings.cpp b/lib/settings.cpp index 4335ce634..03228d45d 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -78,9 +78,11 @@ std::string Settings::addEnabled(const std::string &str) std::set id; id.insert("style"); + id.insert("performance"); + id.insert("portability"); + id.insert("information"); id.insert("missingInclude"); id.insert("unusedFunction"); - id.insert("information"); if (str == "all") { diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 44c3cf9d9..9af60ffb1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10179,7 +10179,8 @@ void Tokenizer::removeUnnecessaryQualification() continue; } - unnecessaryQualificationError(tok, qualification); + if (_settings && _settings->isEnabled("portability")) + unnecessaryQualificationError(tok, qualification); tok->deleteThis(); tok->deleteThis(); diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 651676eef..3fd2a9a61 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -47,7 +47,7 @@ private: errout.str(""); Settings settings; - settings.addEnabled("style"); + settings.addEnabled("portability"); // Tokenize.. Tokenizer tokenizer(&settings, this); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 18367ad3a..0487dc86e 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -45,6 +45,7 @@ private: settings.inconclusive = true; settings.experimental = experimental; settings.addEnabled("style"); + settings.addEnabled("portability"); // Tokenize.. Tokenizer tokenizer(&settings, this); diff --git a/test/testnonreentrantfunctions.cpp b/test/testnonreentrantfunctions.cpp index c155e7a59..5dbcc7016 100644 --- a/test/testnonreentrantfunctions.cpp +++ b/test/testnonreentrantfunctions.cpp @@ -45,7 +45,7 @@ private: Settings settings; settings.posix = true; - settings.addEnabled("style"); + settings.addEnabled("portability"); // Tokenize.. Tokenizer tokenizer(&settings, this); diff --git a/test/testother.cpp b/test/testother.cpp index a494ce253..a0c7812eb 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -213,6 +213,7 @@ private: Settings settings; settings.addEnabled("style"); + settings.addEnabled("performance"); settings.experimental = true; // Preprocess file.. @@ -840,7 +841,7 @@ private: errout.str(""); Settings settings; - settings.addEnabled("style"); + settings.addEnabled("performance"); Tokenizer tokenizer(&settings, this); std::istringstream istr(code); diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index b9d838e70..8b36fcac2 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -41,8 +41,8 @@ private: errout.str(""); Settings settings; - settings.addEnabled("style"); - settings.inconclusive = true; + settings.addEnabled("performance"); + //settings.inconclusive = true; // Tokenize.. Tokenizer tokenizer(&settings, this); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index c5da21f0f..a34f70d62 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -383,6 +383,7 @@ private: errout.str(""); Settings settings; + settings.addEnabled("portability"); Tokenizer tokenizer(&settings, this); std::istringstream istr(code); diff --git a/test/teststl.cpp b/test/teststl.cpp index 991c9403b..d528e2420 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -120,6 +120,7 @@ private: Settings settings; settings.addEnabled("style"); + settings.addEnabled("performance"); // Tokenize.. Tokenizer tokenizer(&settings, this);