r369078 - [analyzer] Analysis: Silence checkers

2019-08-15 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Thu Aug 15 18:53:14 2019
New Revision: 369078

URL: http://llvm.org/viewvc/llvm-project?rev=369078=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=369077=369078=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=369077=369078=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=369077=369078=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 = false);
+  getRegisteredCheckers(bool 

[clang-tools-extra] r369078 - [analyzer] Analysis: Silence checkers

2019-08-15 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Thu Aug 15 18:53:14 2019
New Revision: 369078

URL: http://llvm.org/viewvc/llvm-project?rev=369078=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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=369078=369077=369078=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Aug 15 18:53:14 2019
@@ -334,8 +334,8 @@ static void setStaticAnalyzerCheckerOpts
 
 typedef std::vector> CheckersList;
 
-static CheckersList getCheckersControlList(ClangTidyContext ,
-   bool IncludeExperimental) {
+static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext ,
+   bool IncludeExperimental) {
   CheckersList List;
 
   const auto  =
@@ -419,9 +419,9 @@ ClangTidyASTConsumerFactory::CreateASTCo
 
 #if CLANG_ENABLE_STATIC_ANALYZER
   AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
-  AnalyzerOptions->CheckersControlList =
-  getCheckersControlList(Context, 
Context.canEnableAnalyzerAlphaCheckers());
-  if (!AnalyzerOptions->CheckersControlList.empty()) {
+  AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
+  Context, Context.canEnableAnalyzerAlphaCheckers());
+  if (!AnalyzerOptions->CheckersAndPackages.empty()) {
 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
 AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
@@ -447,7 +447,7 @@ std::vector ClangTidyASTCon
   }
 
 #if CLANG_ENABLE_STATIC_ANALYZER
-  for (const auto  : getCheckersControlList(
+  for (const auto  : getAnalyzerCheckersAndPackages(
Context, Context.canEnableAnalyzerAlphaCheckers()))
 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
 #endif // CLANG_ENABLE_STATIC_ANALYZER


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits