r369845 - [analyzer] Analysis: Fix checker silencing
Csaba Dabis via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 24 05:17:50 PDT 2019
Author: charusso
Date: Sat Aug 24 05:17:49 2019
New Revision: 369845
URL: http://llvm.org/viewvc/llvm-project?rev=369845&view=rev
Log:
[analyzer] Analysis: Fix checker silencing
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/scan-build/bin/scan-build
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=369845&r1=369844&r2=369845&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Aug 24 05:17:49 2019
@@ -464,22 +464,6 @@ static void parseAnalyzerConfigs(Analyze
// At this point, AnalyzerOptions is configured. Let's validate some options.
- if (!Diags)
- return;
-
- if (AnOpts.ShouldTrackConditionsDebug && !AnOpts.ShouldTrackConditions)
- Diags->Report(diag::err_analyzer_config_invalid_input)
- << "track-conditions-debug" << "'track-conditions' to also be enabled";
-
- if (!AnOpts.CTUDir.empty() && !llvm::sys::fs::is_directory(AnOpts.CTUDir))
- Diags->Report(diag::err_analyzer_config_invalid_input) << "ctu-dir"
- << "a filename";
-
- if (!AnOpts.ModelPath.empty() &&
- !llvm::sys::fs::is_directory(AnOpts.ModelPath))
- Diags->Report(diag::err_analyzer_config_invalid_input) << "model-path"
- << "a filename";
-
// FIXME: Here we try to validate the silenced checkers or packages are valid.
// The current approach only validates the registered checkers which does not
// contain the runtime enabled checkers and optimally we would validate both.
@@ -493,18 +477,37 @@ static void parseAnalyzerConfigs(Analyze
AnOpts.RawSilencedCheckersAndPackages.split(CheckersAndPackages, ";");
for (const StringRef CheckerOrPackage : CheckersAndPackages) {
- bool IsChecker = CheckerOrPackage.contains('.');
- bool IsValidName =
- IsChecker ? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
- : llvm::find(Packages, CheckerOrPackage) != Packages.end();
-
- if (!IsValidName)
- Diags->Report(diag::err_unknown_analyzer_checker_or_package)
- << CheckerOrPackage;
+ if (Diags) {
+ bool IsChecker = CheckerOrPackage.contains('.');
+ bool IsValidName =
+ IsChecker
+ ? llvm::find(Checkers, CheckerOrPackage) != Checkers.end()
+ : llvm::find(Packages, CheckerOrPackage) != Packages.end();
+
+ if (!IsValidName)
+ Diags->Report(diag::err_unknown_analyzer_checker_or_package)
+ << CheckerOrPackage;
+ }
AnOpts.SilencedCheckersAndPackages.emplace_back(CheckerOrPackage);
}
}
+
+ if (!Diags)
+ return;
+
+ if (AnOpts.ShouldTrackConditionsDebug && !AnOpts.ShouldTrackConditions)
+ Diags->Report(diag::err_analyzer_config_invalid_input)
+ << "track-conditions-debug" << "'track-conditions' to also be enabled";
+
+ if (!AnOpts.CTUDir.empty() && !llvm::sys::fs::is_directory(AnOpts.CTUDir))
+ Diags->Report(diag::err_analyzer_config_invalid_input) << "ctu-dir"
+ << "a filename";
+
+ if (!AnOpts.ModelPath.empty() &&
+ !llvm::sys::fs::is_directory(AnOpts.ModelPath))
+ Diags->Report(diag::err_analyzer_config_invalid_input) << "model-path"
+ << "a filename";
}
static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
Modified: cfe/trunk/tools/scan-build/bin/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/bin/scan-build?rev=369845&r1=369844&r2=369845&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/bin/scan-build (original)
+++ cfe/trunk/tools/scan-build/bin/scan-build Sat Aug 24 05:17:49 2019
@@ -1889,11 +1889,6 @@ foreach (sort { $Options{DisableCheckers
# Push checkers in order they were disabled.
push @AnalysesToRun, "-analyzer-disable-checker", $_;
}
-foreach (sort { $Options{SilenceCheckers}{$a} <=> $Options{SilenceCheckers}{$b} }
- keys %{$Options{SilenceCheckers}}) {
- # Push checkers in order they were silenced.
- push @AnalysesToRun, "-analyzer-config silence-checker", $_;
-}
if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; }
if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; }
if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; }
@@ -1903,6 +1898,14 @@ if ($Options{MaxLoop} > 0) { push @Analy
my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun;
my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}};
my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}};
+
+foreach (sort { $Options{SilenceCheckers}{$a} <=> $Options{SilenceCheckers}{$b} }
+ keys %{$Options{SilenceCheckers}}) {
+ # Add checkers in order they were silenced.
+ $CCC_ANALYZER_CONFIG =
+ $CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers=".$_;
+}
+
my %EnvVars = (
'CC' => $Cmd,
'CXX' => $CmdCXX,
More information about the cfe-commits
mailing list