enable: break out 'performance' and 'portability' from the 'style' id. Ticket: #3074
This commit is contained in:
parent
92c2df0a28
commit
d23c58d387
|
@ -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"
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -1057,7 +1057,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
|
|||
if (varid && Token::Match(tok, "= %varid% + %num% ;", varid))
|
||||
{
|
||||
const MathLib::bigint index = MathLib::toLongNumber(tok->strAt(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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -35,7 +35,7 @@ CheckPostfixOperator instance;
|
|||
|
||||
void CheckPostfixOperator::postfixOperator()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled("performance"))
|
||||
return;
|
||||
|
||||
const Token *tok = _tokenizer->tokens();
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -78,9 +78,11 @@ std::string Settings::addEnabled(const std::string &str)
|
|||
|
||||
std::set<std::string> 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")
|
||||
{
|
||||
|
|
|
@ -10179,7 +10179,8 @@ void Tokenizer::removeUnnecessaryQualification()
|
|||
continue;
|
||||
}
|
||||
|
||||
unnecessaryQualificationError(tok, qualification);
|
||||
if (_settings && _settings->isEnabled("portability"))
|
||||
unnecessaryQualificationError(tok, qualification);
|
||||
|
||||
tok->deleteThis();
|
||||
tok->deleteThis();
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
errout.str("");
|
||||
|
||||
Settings settings;
|
||||
settings.addEnabled("style");
|
||||
settings.addEnabled("portability");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
settings.inconclusive = true;
|
||||
settings.experimental = experimental;
|
||||
settings.addEnabled("style");
|
||||
settings.addEnabled("portability");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
|
||||
Settings settings;
|
||||
settings.posix = true;
|
||||
settings.addEnabled("style");
|
||||
settings.addEnabled("portability");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -383,6 +383,7 @@ private:
|
|||
errout.str("");
|
||||
|
||||
Settings settings;
|
||||
settings.addEnabled("portability");
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
||||
std::istringstream istr(code);
|
||||
|
|
|
@ -120,6 +120,7 @@ private:
|
|||
|
||||
Settings settings;
|
||||
settings.addEnabled("style");
|
||||
settings.addEnabled("performance");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
|
|
Loading…
Reference in New Issue