Skip to content

Commit

Permalink
[analyzer] Preserve the order checkers were enabled/disabled.
Browse files Browse the repository at this point in the history
In addition to r251524: preserve the order the checkers were enabled/disabled to be deterministic.
Additionally return the number of arguments read by 'ProcessArgs' - for debug purpose.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251552 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ayartsev7 committed Oct 28, 2015
1 parent 07c6519 commit 78cbefb
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tools/scan-build/scan-build
Original file line number Diff line number Diff line change
Expand Up @@ -1447,9 +1447,12 @@ my $ForceDisplayHelp = 0;

sub ProcessArgs {
my $Args = shift;
my $NumArgs = 0;

while (@$Args) {

$NumArgs++;

# Scan for options we recognize.

my $arg = $Args->[0];
Expand Down Expand Up @@ -1631,15 +1634,17 @@ sub ProcessArgs {
if ($arg eq "-enable-checker") {
shift @$Args;
my $Checker = shift @$Args;
$Options{EnableCheckers}{$Checker} = 1;
# Store $NumArgs to preserve the order the checkers were enabled.
$Options{EnableCheckers}{$Checker} = $NumArgs;
delete $Options{DisableCheckers}{$Checker};
next;
}

if ($arg eq "-disable-checker") {
shift @$Args;
my $Checker = shift @$Args;
$Options{DisableCheckers}{$Checker} = 1;
# Store $NumArgs to preserve the order the checkers were disabled.
$Options{DisableCheckers}{$Checker} = $NumArgs;
delete $Options{EnableCheckers}{$Checker};
next;
}
Expand Down Expand Up @@ -1676,8 +1681,10 @@ sub ProcessArgs {

DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);

$NumArgs--;
last;
}
return $NumArgs;
}

if (!@ARGV) {
Expand Down Expand Up @@ -1751,8 +1758,16 @@ Diag("Using '$Clang' for static analysis\n");
SetHtmlEnv(\@ARGV, $Options{OutputDir});

my @AnalysesToRun;
foreach (keys %{$Options{EnableCheckers}}) { push @AnalysesToRun, "-analyzer-checker", $_; }
foreach (keys %{$Options{DisableCheckers}}) { push @AnalysesToRun, "-analyzer-disable-checker", $_; }
foreach (sort { $Options{EnableCheckers}{$a} <=> $Options{EnableCheckers}{$b} }
keys %{$Options{EnableCheckers}}) {
# Push checkers in order they were enabled.
push @AnalysesToRun, "-analyzer-checker", $_;
}
foreach (sort { $Options{DisableCheckers}{$a} <=> $Options{DisableCheckers}{$b} }
keys %{$Options{DisableCheckers}}) {
# Push checkers in order they were disabled.
push @AnalysesToRun, "-analyzer-disable-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}"; }
Expand Down

0 comments on commit 78cbefb

Please sign in to comment.