Skip to content
Open
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
5 changes: 3 additions & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ class CppCheck::CppCheckLogger : public ErrorLogger
const auto errorMessage = SuppressionList::ErrorMessage::fromErrorMessage(msg, macroNames);

bool suppressed = false;
bool inlineSupressed;

if (mSuppressions.nomsg.isSuppressed(errorMessage, mUseGlobalSuppressions)) {
if (mSuppressions.nomsg.isSuppressed(errorMessage, mUseGlobalSuppressions, &inlineSupressed)) {
// Safety: Report critical errors to ErrorLogger
if (mSettings.safety && ErrorLogger::isCriticalErrorId(msg.id)) {
mExitCode = 1;
Expand Down Expand Up @@ -220,7 +221,7 @@ class CppCheck::CppCheckLogger : public ErrorLogger
if (!mSettings.emitDuplicates && !mErrorList.emplace(std::move(errmsg)).second)
return;

if (mAnalyzerInformation)
if (mAnalyzerInformation && !inlineSupressed)
mAnalyzerInformation->reportErr(msg);

if (suppressed)
Expand Down
11 changes: 7 additions & 4 deletions lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ bool SuppressionList::Suppression::isMatch(const SuppressionList::ErrorMessage &
cppcheck::unreachable();
}

bool SuppressionList::isSuppressed(const SuppressionList::ErrorMessage &errmsg, bool global)
{
bool SuppressionList::isSuppressed(const SuppressionList::ErrorMessage &errmsg, bool global, bool *inlineSupressed) {
std::lock_guard<std::mutex> lg(mSuppressionsSync);

if (inlineSupressed)
*inlineSupressed = false;
// TODO: handle unmatchedPolyspaceSuppression?
const bool unmatchedSuppression(errmsg.errorId == "unmatchedSuppression");
bool returnValue = false;
Expand All @@ -484,8 +484,11 @@ bool SuppressionList::isSuppressed(const SuppressionList::ErrorMessage &errmsg,
continue;
if (unmatchedSuppression && s.errorId != errmsg.errorId)
continue;
if (s.isMatch(errmsg))
if (s.isMatch(errmsg)) {
returnValue = true;
if (inlineSupressed && s.isInline)
*inlineSupressed = true;
}
}
return returnValue;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/suppressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ class CPPCHECKLIB SuppressionList {
* @brief Returns true if this message should not be shown to the user.
* @param errmsg error message
* @param global use global suppressions
* @param inlineSupressed is true if there exists an inline suppression for this error
* @return true if this error is suppressed.
*/
bool isSuppressed(const ErrorMessage &errmsg, bool global = true);
bool isSuppressed(const ErrorMessage &errmsg, bool global = true, bool *inlineSupressed = nullptr);

/**
* @brief Returns true if this message is "explicitly" suppressed. The suppression "id" must match textually exactly.
Expand Down
Loading