Author: charusso
Date: Thu Aug 15 18:53:14 2019
New Revision: 369078
URL: http://llvm.org/viewvc/llvm-project?rev=369078&view=rev
Log:
[analyzer] Analysis: Silence checkers
Summary:
This patch introduces a new `analyzer-config` configuration:
`-analyzer-config silence-checkers`
which could be used to silence the given checkers.
It accepts a semicolon separated list, packed into quotation marks, e.g:
`-analyzer-config silence-checkers="core.DivideZero;core.NullDereference"`
It could be used to "disable" core checkers, so they model the analysis as
before, just if some of them are too noisy it prevents to emit reports.
This patch also adds support for that new option to the scan-build.
Passing the option `-disable-checker core.DivideZero` to the scan-build
will be transferred to `-analyzer-config silence-checkers=core.DivideZero`.
Reviewed By: NoQ, Szelethus
Differential Revision: https://reviews.llvm.org/D66042
Added:
cfe/trunk/test/Analysis/silence-checkers-and-packages-core-all.cpp
cfe/trunk/test/Analysis/silence-checkers-and-packages-core-div-by-zero.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/tools/scan-build/bin/scan-build
cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=369078&r1=369077&r2=369078&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Aug 15 18:53:14
2019
@@ -300,7 +300,7 @@ def err_omp_more_one_clause : Error<
"directive '#pragma omp %0' cannot contain more than one '%1'
clause%select{| with '%3' name modifier| with 'source' dependence}2">;
// Static Analyzer Core
-def err_unknown_analyzer_checker : Error<
+def err_unknown_analyzer_checker_or_package : Error<
"no analyzer checkers or packages are associated with '%0'">;
def note_suggest_disabling_all_checkers : Note<
"use -analyzer-disable-all-checks to disable all static analyzer
checkers">;
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=369078&r1=369077&r2=369078&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Thu Aug 15
18:53:14 2019
@@ -380,12 +380,6 @@ ANALYZER_OPTION(
"Value: \"constructors\", \"destructors\", \"methods\".",
"destructors")
-ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
-StringRef, IPAMode, "ipa",
-"Controls the mode of inter-procedural analysis. Value: \"none\", "
-"\"basic-inlining\", \"inlining\", \"dynamic\", \"dynamic-bifurcate\".",
-/* SHALLOW_VAL */ "inlining", /* DEEP_VAL */ "dynamic-bifurcate")
-
ANALYZER_OPTION(
StringRef, ExplorationStrategy, "exploration_strategy",
"Value: \"dfs\", \"bfs\", \"unexplored_first\", "
@@ -393,5 +387,17 @@ ANALYZER_OPTION(
"\"bfs_block_dfs_contents\".",
"unexplored_first_queue")
+ANALYZER_OPTION(
+StringRef, RawSilencedCheckersAndPackages, "silence-checkers",
+"A semicolon separated list of checker and package names to silence. "
+"Silenced checkers will not emit reports, but the modeling remain
enabled.",
+"")
+
+ANALYZER_OPTION_DEPENDS_ON_USER_MODE(
+StringRef, IPAMode, "ipa",
+"Controls the mode of inter-procedural analysis. Value: \"none\", "
+"\"basic-inlining\", \"inlining\", \"dynamic\", \"dynamic-bifurcate\".",
+/* SHALLOW_VAL */ "inlining", /* DEEP_VAL */ "dynamic-bifurcate")
+
#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
#undef ANALYZER_OPTION
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=369078&r1=369077&r2=369078&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Thu Aug 15
18:53:14 2019
@@ -164,7 +164,40 @@ public:
using ConfigTable = llvm::StringMap;
static std::vector
- getRegisteredCheckers(bool IncludeExperimental = fa