Skip to content
Snippets Groups Projects
Commit 4f183b9d authored by Anton Yartsev's avatar Anton Yartsev
Browse files

[analyzer] Make inclusion/exclusion of checkers less ambiguous.

A checker may be enabled/disabled multiple times via -enable-checker and -disable-checker scan-build arguments. Currently the conflicting and repetitive arguments are passed to the analyzer as is.
With this patch only the last enable/disable of a particular checker is accepted and passed to the analyzer.
This change is mostly done for the upcoming 'config for scan-build' patch when multiple inclusions/exclusions of a checker are expected to be more common.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251524 91177308-0d34-0410-b5e6-96231b3b80d8
parent ea62bd9c
No related branches found
No related tags found
No related merge requests found
...@@ -54,8 +54,8 @@ my %Options = ( ...@@ -54,8 +54,8 @@ my %Options = (
ViewResults => 0, # View results when the build terminates. ViewResults => 0, # View results when the build terminates.
ExitStatusFoundBugs => 0, # Exit status reflects whether bugs were found ExitStatusFoundBugs => 0, # Exit status reflects whether bugs were found
KeepEmpty => 0, # Don't remove output directory even with 0 results. KeepEmpty => 0, # Don't remove output directory even with 0 results.
EnableCheckers => [], EnableCheckers => {},
DisableCheckers => [], DisableCheckers => {},
UseCC => undef, # C compiler to use for compilation. UseCC => undef, # C compiler to use for compilation.
UseCXX => undef, # C++ compiler to use for compilation. UseCXX => undef, # C++ compiler to use for compilation.
AnalyzerTarget => undef, AnalyzerTarget => undef,
...@@ -1630,13 +1630,17 @@ sub ProcessArgs { ...@@ -1630,13 +1630,17 @@ sub ProcessArgs {
if ($arg eq "-enable-checker") { if ($arg eq "-enable-checker") {
shift @$Args; shift @$Args;
push @{$Options{EnableCheckers}}, shift @$Args; my $Checker = shift @$Args;
$Options{EnableCheckers}{$Checker} = 1;
delete $Options{DisableCheckers}{$Checker};
next; next;
} }
if ($arg eq "-disable-checker") { if ($arg eq "-disable-checker") {
shift @$Args; shift @$Args;
push @{$Options{DisableCheckers}}, shift @$Args; my $Checker = shift @$Args;
$Options{DisableCheckers}{$Checker} = 1;
delete $Options{EnableCheckers}{$Checker};
next; next;
} }
...@@ -1747,8 +1751,8 @@ Diag("Using '$Clang' for static analysis\n"); ...@@ -1747,8 +1751,8 @@ Diag("Using '$Clang' for static analysis\n");
SetHtmlEnv(\@ARGV, $Options{OutputDir}); SetHtmlEnv(\@ARGV, $Options{OutputDir});
my @AnalysesToRun; my @AnalysesToRun;
foreach (@{$Options{EnableCheckers}}) { push @AnalysesToRun, "-analyzer-checker", $_; } foreach (keys %{$Options{EnableCheckers}}) { push @AnalysesToRun, "-analyzer-checker", $_; }
foreach (@{$Options{DisableCheckers}}) { push @AnalysesToRun, "-analyzer-disable-checker", $_; } foreach (keys %{$Options{DisableCheckers}}) { push @AnalysesToRun, "-analyzer-disable-checker", $_; }
if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; } if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; }
if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; } if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; }
if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; } if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment