diff --git a/lib/check.cpp b/lib/check.cpp index dc4385e4e..fb3f6b054 100644 --- a/lib/check.cpp +++ b/lib/check.cpp @@ -48,7 +48,7 @@ void Check::reportError(const ErrorMessage &errmsg) void Check::reportError(const std::list &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 &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 diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index c19c3e2e3..b518fb659 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -297,7 +297,7 @@ void CheckMemoryLeak::reportErr(const Token *tok, Severity::SeverityType severit void CheckMemoryLeak::reportErr(const std::list &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 diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 2e598d46b..5a68396df 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -120,7 +120,7 @@ ErrorMessage::ErrorMessage(const std::list& callstack, const Token } -ErrorMessage::ErrorMessage(const std::list& 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& 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& 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) diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 17c503c4b..bc6bf6c33 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -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); diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index bf8d24754..8ddea84d0 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -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);