Added Settings::stupid flag that can be used to hide checking that generates false positives.
This commit is contained in:
parent
1178d47a9b
commit
30ee9ba6e4
|
@ -1122,8 +1122,8 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
||||||
{
|
{
|
||||||
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId()))
|
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId()))
|
||||||
{
|
{
|
||||||
// this is currently inconclusive. See TestBufferOverrun::terminateStrncpy3
|
// this is currently 'stupid'. See TestBufferOverrun::terminateStrncpy3
|
||||||
if (_settings->inconclusive)
|
if (_settings->stupid)
|
||||||
terminateStrncpyError(tok);
|
terminateStrncpyError(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ void CheckClass::virtualDestructor()
|
||||||
// * base class doesn't have virtual destructor
|
// * base class doesn't have virtual destructor
|
||||||
// * derived class has non-empty destructor
|
// * derived class has non-empty destructor
|
||||||
// * base class is deleted
|
// * base class is deleted
|
||||||
if (!_settings->inconclusive)
|
if (!_settings->stupid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
createSymbolDatabase();
|
createSymbolDatabase();
|
||||||
|
|
|
@ -774,7 +774,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
||||||
--parlevel;
|
--parlevel;
|
||||||
if (parlevel < 1)
|
if (parlevel < 1)
|
||||||
{
|
{
|
||||||
return (eq || _settings->inconclusive) ? 0 : "callfunc";
|
return (eq || _settings->stupid) ? 0 : "callfunc";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2024,7 +2024,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the "if break|continue ;" that follows "dealloc ; alloc ;"
|
// Remove the "if break|continue ;" that follows "dealloc ; alloc ;"
|
||||||
if (! _settings->inconclusive && Token::Match(tok2, "dealloc ; alloc ; if break|continue ;"))
|
if (! _settings->stupid && Token::Match(tok2, "dealloc ; alloc ; if break|continue ;"))
|
||||||
{
|
{
|
||||||
tok2 = tok2->tokAt(3);
|
tok2 = tok2->tokAt(3);
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||||
|
@ -2290,7 +2290,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If "--all" is given, remove all "callfunc"..
|
// If "--all" is given, remove all "callfunc"..
|
||||||
if (done && _settings->inconclusive)
|
if (done && _settings->stupid)
|
||||||
{
|
{
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -354,7 +354,7 @@ void CheckOther::checkRedundantAssignmentInSwitch()
|
||||||
|
|
||||||
void CheckOther::checkSwitchCaseFallThrough()
|
void CheckOther::checkSwitchCaseFallThrough()
|
||||||
{
|
{
|
||||||
if (!(_settings->_checkCodingStyle && _settings->inconclusive))
|
if (!(_settings->_checkCodingStyle && _settings->stupid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char switchPattern[] = "switch (";
|
const char switchPattern[] = "switch (";
|
||||||
|
|
|
@ -477,7 +477,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
|
|
||||||
// First check for a "fall through" comment match, but only
|
// First check for a "fall through" comment match, but only
|
||||||
// add a suppression if the next token is 'case' or 'default'
|
// add a suppression if the next token is 'case' or 'default'
|
||||||
if (_settings->_checkCodingStyle && _settings->inconclusive && fallThroughComment)
|
if (_settings->_checkCodingStyle && _settings->stupid && fallThroughComment)
|
||||||
{
|
{
|
||||||
std::string::size_type j = str.find_first_not_of("abcdefghijklmnopqrstuvwxyz", i);
|
std::string::size_type j = str.find_first_not_of("abcdefghijklmnopqrstuvwxyz", i);
|
||||||
std::string tok = str.substr(i, j - i);
|
std::string tok = str.substr(i, j - i);
|
||||||
|
|
|
@ -43,6 +43,7 @@ Settings::Settings()
|
||||||
_append = "";
|
_append = "";
|
||||||
_terminate = false;
|
_terminate = false;
|
||||||
inconclusive = false;
|
inconclusive = false;
|
||||||
|
stupid = false;
|
||||||
test_2_pass = false;
|
test_2_pass = false;
|
||||||
reportProgress = false;
|
reportProgress = false;
|
||||||
ifcfg = false;
|
ifcfg = false;
|
||||||
|
|
|
@ -58,6 +58,13 @@ public:
|
||||||
/** @brief Inconclusive checks */
|
/** @brief Inconclusive checks */
|
||||||
bool inconclusive;
|
bool inconclusive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief enables stupid checks that generates false positives because they are not clever enough.
|
||||||
|
* This flag should only be used temporarily by the check until it is fixed.
|
||||||
|
* There is no way to enable this flag from the command line.
|
||||||
|
*/
|
||||||
|
bool stupid;
|
||||||
|
|
||||||
/** @brief Is --style given? */
|
/** @brief Is --style given? */
|
||||||
bool _checkCodingStyle;
|
bool _checkCodingStyle;
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,13 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void check(const char code[], bool inconclusive = true)
|
void check(const char code[], bool stupid = true)
|
||||||
{
|
{
|
||||||
// Clear the error buffer..
|
// Clear the error buffer..
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.inconclusive = inconclusive;
|
settings.stupid = stupid;
|
||||||
settings._checkCodingStyle = true;
|
settings._checkCodingStyle = true;
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
|
|
|
@ -1382,7 +1382,7 @@ private:
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.inconclusive = true;
|
settings.stupid = true;
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
|
|
|
@ -127,13 +127,13 @@ public:
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void check(const char code[], bool inconclusive = false)
|
void check(const char code[], bool stupid = false)
|
||||||
{
|
{
|
||||||
// Clear the error buffer..
|
// Clear the error buffer..
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.inconclusive = inconclusive;
|
settings.stupid = stupid;
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
|
@ -2994,7 +2994,7 @@ private:
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.inconclusive = true;
|
settings.stupid = true;
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
|
@ -3707,7 +3707,6 @@ private:
|
||||||
/**
|
/**
|
||||||
* Tokenize and execute leak check for given code
|
* Tokenize and execute leak check for given code
|
||||||
* @param code Source code
|
* @param code Source code
|
||||||
* @param inconclusive inconclusive checking
|
|
||||||
*/
|
*/
|
||||||
void check(const char code[])
|
void check(const char code[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -193,7 +193,7 @@ private:
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings._checkCodingStyle = true;
|
settings._checkCodingStyle = true;
|
||||||
settings.inconclusive = true;
|
settings.stupid = true;
|
||||||
|
|
||||||
// Preprocess file..
|
// Preprocess file..
|
||||||
Preprocessor preprocessor(&settings, this);
|
Preprocessor preprocessor(&settings, this);
|
||||||
|
|
Loading…
Reference in New Issue