Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
std::exit(EXIT_FAILURE);
}

if (!mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage())) {
if (!mSettings.nomsg.isSuppressed(msg)) {
// Alert only about unique errors
std::string errmsg = msg.toString(mSettings.verbose);
if (std::find(mErrorList.cbegin(), mErrorList.cend(), errmsg) == mErrorList.cend()) {
Expand Down Expand Up @@ -376,7 +376,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
"cppcheckError",
Certainty::normal);

if (!mSettings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
if (!mSettings.nomsg.isSuppressed(errmsg))
mErrorLogger.reportErr(errmsg);
}

Expand Down
2 changes: 1 addition & 1 deletion cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ThreadExecutor::SyncLogForwarder : public ErrorLogger

void report(const ErrorMessage &msg, MessageType msgType)
{
if (mThreadExecutor.mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
if (mThreadExecutor.mSettings.nomsg.isSuppressed(msg))
return;

// Alert only about unique errors
Expand Down
4 changes: 2 additions & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,7 @@ void CppCheck::reportErr(const ErrorMessage &msg)
if (!mSettings.buildDir.empty())
mAnalyzerInformation.reportErr(msg);

// TODO: only convert if necessary
const Suppressions::ErrorMessage errorMessage = msg.toSuppressionsErrorMessage();

if (mUseGlobalSuppressions) {
Expand Down Expand Up @@ -1653,8 +1654,7 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c

void CppCheck::reportInfo(const ErrorMessage &msg)
{
const Suppressions::ErrorMessage &errorMessage = msg.toSuppressionsErrorMessage();
if (!mSettings.nomsg.isSuppressed(errorMessage))
if (!mSettings.nomsg.isSuppressed(msg))
mErrorLogger.reportInfo(msg);
}

Expand Down
7 changes: 7 additions & 0 deletions lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,13 @@ bool Suppressions::isSuppressed(const Suppressions::ErrorMessage &errmsg)
return false;
}

bool Suppressions::isSuppressed(const ::ErrorMessage &errmsg)
{
if (mSuppressions.empty())
return false;
return isSuppressed(errmsg.toSuppressionsErrorMessage());
}

bool Suppressions::isSuppressedLocal(const Suppressions::ErrorMessage &errmsg)
{
const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression");
Expand Down
8 changes: 8 additions & 0 deletions lib/suppressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
/// @{

class Tokenizer;
class ErrorMessage;

/** @brief class for handling suppressions */
class CPPCHECKLIB Suppressions {
Expand Down Expand Up @@ -178,6 +179,13 @@ class CPPCHECKLIB Suppressions {
*/
bool isSuppressed(const ErrorMessage &errmsg);

/**
* @brief Returns true if this message should not be shown to the user.
* @param errmsg error message
* @return true if this error is suppressed.
*/
bool isSuppressed(const ::ErrorMessage &errmsg);

/**
* @brief Returns true if this message should not be shown to the user, only uses local suppressions.
* @param errmsg error message
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SimpleSuppressor : public ErrorLogger {
next->reportOut(outmsg);
}
void reportErr(const ErrorMessage &msg) override {
if (!msg.callStack.empty() && !settings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
if (!msg.callStack.empty() && !settings.nomsg.isSuppressed(msg))
next->reportErr(msg);
}
private:
Expand Down