Skip calculateWarningHash if we are not in bugHunting (#3047)

This commit is contained in:
Ken-Patrick Lehrmann 2021-01-13 18:38:00 +01:00 committed by GitHub
parent c94713c607
commit 56124f0c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 10 deletions

View File

@ -48,7 +48,7 @@ void Check::reportError(const ErrorMessage &errmsg)
void Check::reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe, bool inconclusive)
{
const ErrorMessage errmsg(callstack, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, inconclusive);
const ErrorMessage errmsg(callstack, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, inconclusive, mSettings ? mSettings->bugHunting : false);
if (mErrorLogger)
mErrorLogger->reportErr(errmsg);
else
@ -57,7 +57,7 @@ void Check::reportError(const std::list<const Token *> &callstack, Severity::Sev
void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, bool inconclusive)
{
const ErrorMessage errmsg(errorPath, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, inconclusive);
const ErrorMessage errmsg(errorPath, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, inconclusive, mSettings ? mSettings->bugHunting : false);
if (mErrorLogger)
mErrorLogger->reportErr(errmsg);
else

View File

@ -297,7 +297,7 @@ void CheckMemoryLeak::reportErr(const Token *tok, Severity::SeverityType severit
void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const
{
const ErrorMessage errmsg(callstack, mTokenizer_ ? &mTokenizer_->list : nullptr, severity, id, msg, cwe, false);
const ErrorMessage errmsg(callstack, mTokenizer_ ? &mTokenizer_->list : nullptr, severity, id, msg, cwe, false, mSettings_->bugHunting);
if (mErrorLogger_)
mErrorLogger_->reportErr(errmsg);
else

View File

@ -120,7 +120,7 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
}
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, const std::string& id, const std::string& msg, const CWE &cwe, bool inconclusive)
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, const std::string& id, const std::string& msg, const CWE &cwe, bool inconclusive, bool bugHunting)
: id(id), incomplete(false), severity(severity), cwe(cwe.id), inconclusive(inconclusive)
{
// Format callstack
@ -142,10 +142,10 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
hashWarning << std::hex << (tok ? tok->index() : 0) << " ";
hashWarning << mShortMessage;
hash = calculateWarningHash(list, hashWarning.str());
hash = bugHunting ? calculateWarningHash(list, hashWarning.str()) : 0;
}
ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenList, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, bool inconclusive)
ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenList, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, bool inconclusive, bool bugHunting)
: id(id), incomplete(false), severity(severity), cwe(cwe.id), inconclusive(inconclusive)
{
// Format callstack
@ -174,7 +174,7 @@ ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenLis
hashWarning << std::hex << (e.first ? e.first->index() : 0) << " ";
hashWarning << mShortMessage;
hash = calculateWarningHash(tokenList, hashWarning.str());
hash = bugHunting ? calculateWarningHash(tokenList, hashWarning.str()) : 0;
}
ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)

View File

@ -147,14 +147,16 @@ public:
const std::string& id,
const std::string& msg,
const CWE &cwe,
bool inconclusive);
bool inconclusive,
bool bugHunting);
ErrorMessage(const ErrorPath &errorPath,
const TokenList *tokenList,
Severity::SeverityType severity,
const char id[],
const std::string &msg,
const CWE &cwe,
bool inconclusive);
bool inconclusive,
bool bugHunting);
ErrorMessage();
explicit ErrorMessage(const tinyxml2::XMLElement * const errmsg);

View File

@ -642,7 +642,7 @@ namespace {
ErrorPath e = errorPath;
e.push_back(ErrorPathItem(tok, text));
ErrorMessage errmsg(e, &tokenizer->list, severity, id, text, cwe, inconclusive);
ErrorMessage errmsg(e, &tokenizer->list, severity, id, text, cwe, inconclusive, true);
errmsg.incomplete = incomplete;
errmsg.function = functionName.empty() ? currentFunction : functionName;
errorLogger->reportErr(errmsg);