Skip calculateWarningHash if we are not in bugHunting (#3047)
This commit is contained in:
parent
c94713c607
commit
56124f0c5d
|
@ -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)
|
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)
|
if (mErrorLogger)
|
||||||
mErrorLogger->reportErr(errmsg);
|
mErrorLogger->reportErr(errmsg);
|
||||||
else
|
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)
|
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)
|
if (mErrorLogger)
|
||||||
mErrorLogger->reportErr(errmsg);
|
mErrorLogger->reportErr(errmsg);
|
||||||
else
|
else
|
||||||
|
|
|
@ -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
|
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_)
|
if (mErrorLogger_)
|
||||||
mErrorLogger_->reportErr(errmsg);
|
mErrorLogger_->reportErr(errmsg);
|
||||||
else
|
else
|
||||||
|
|
|
@ -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)
|
: id(id), incomplete(false), severity(severity), cwe(cwe.id), inconclusive(inconclusive)
|
||||||
{
|
{
|
||||||
// Format callstack
|
// Format callstack
|
||||||
|
@ -142,10 +142,10 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
|
||||||
hashWarning << std::hex << (tok ? tok->index() : 0) << " ";
|
hashWarning << std::hex << (tok ? tok->index() : 0) << " ";
|
||||||
hashWarning << mShortMessage;
|
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)
|
: id(id), incomplete(false), severity(severity), cwe(cwe.id), inconclusive(inconclusive)
|
||||||
{
|
{
|
||||||
// Format callstack
|
// Format callstack
|
||||||
|
@ -174,7 +174,7 @@ ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenLis
|
||||||
hashWarning << std::hex << (e.first ? e.first->index() : 0) << " ";
|
hashWarning << std::hex << (e.first ? e.first->index() : 0) << " ";
|
||||||
hashWarning << mShortMessage;
|
hashWarning << mShortMessage;
|
||||||
|
|
||||||
hash = calculateWarningHash(tokenList, hashWarning.str());
|
hash = bugHunting ? calculateWarningHash(tokenList, hashWarning.str()) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
|
ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
|
||||||
|
|
|
@ -147,14 +147,16 @@ public:
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
const CWE &cwe,
|
const CWE &cwe,
|
||||||
bool inconclusive);
|
bool inconclusive,
|
||||||
|
bool bugHunting);
|
||||||
ErrorMessage(const ErrorPath &errorPath,
|
ErrorMessage(const ErrorPath &errorPath,
|
||||||
const TokenList *tokenList,
|
const TokenList *tokenList,
|
||||||
Severity::SeverityType severity,
|
Severity::SeverityType severity,
|
||||||
const char id[],
|
const char id[],
|
||||||
const std::string &msg,
|
const std::string &msg,
|
||||||
const CWE &cwe,
|
const CWE &cwe,
|
||||||
bool inconclusive);
|
bool inconclusive,
|
||||||
|
bool bugHunting);
|
||||||
ErrorMessage();
|
ErrorMessage();
|
||||||
explicit ErrorMessage(const tinyxml2::XMLElement * const errmsg);
|
explicit ErrorMessage(const tinyxml2::XMLElement * const errmsg);
|
||||||
|
|
||||||
|
|
|
@ -642,7 +642,7 @@ namespace {
|
||||||
|
|
||||||
ErrorPath e = errorPath;
|
ErrorPath e = errorPath;
|
||||||
e.push_back(ErrorPathItem(tok, text));
|
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.incomplete = incomplete;
|
||||||
errmsg.function = functionName.empty() ? currentFunction : functionName;
|
errmsg.function = functionName.empty() ? currentFunction : functionName;
|
||||||
errorLogger->reportErr(errmsg);
|
errorLogger->reportErr(errmsg);
|
||||||
|
|
Loading…
Reference in New Issue