Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1989,13 +1989,6 @@ const SourceManager &SM = getSourceManager(); const AnalyzerOptions &Opts = getAnalyzerOptions(); - // See whether we need to silence the checker/package. - // FIXME: This will not work if the report was emitted with an incorrect tag. - for (const std::string &CheckerOrPackage : Opts.SilencedCheckersAndPackages) { - if (R->getBugType().getCheckerName().startswith(CheckerOrPackage)) - return nullptr; - } - if (!PDC->shouldGenerateDiagnostics()) return generateEmptyDiagnosticForReport(R, getSourceManager()); @@ -3040,6 +3033,14 @@ if (!report) return; + // See whether we need to silence the checker/package. + for (const std::string &CheckerOrPackage : + getAnalyzerOptions().SilencedCheckersAndPackages) { + if (report->getBugType().getCheckerName().startswith( + CheckerOrPackage)) + return; + } + ArrayRef Consumers = getPathDiagnosticConsumers(); std::unique_ptr Diagnostics = generateDiagnosticForConsumerMap(report, Consumers, bugReports); Index: clang/test/Analysis/silence-checkers.cpp =================================================================== --- clang/test/Analysis/silence-checkers.cpp +++ clang/test/Analysis/silence-checkers.cpp @@ -11,6 +11,12 @@ // RUN: -analyzer-checker=cplusplus.NewDelete\ // RUN: -analyzer-config silence-checkers="unix" +// RUN: %clang_analyze_cc1 -verify="deadstore-silenced" %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=apiModeling \ +// RUN: -analyzer-checker=deadcode \ +// RUN: -analyzer-config silence-checkers="deadcode.DeadStores" + #include "Inputs/system-header-simulator-cxx.h" typedef __typeof(sizeof(int)) size_t; @@ -38,3 +44,17 @@ delete Ptr; // no-silence-warning{{Argument to 'delete' is a constant address (16), which is not memory allocated by 'new' [cplusplus.NewDelete]}} // unix-silenced-warning@-1{{Argument to 'delete' is a constant address (16), which is not memory allocated by 'new' [cplusplus.NewDelete]}} } + +// deadstore-silenced-no-diagnostics + +int foo() { + int x = 42; + return x; +} + +void g() { + int y; + y = 7; + int x = foo(); + y = 10; +}