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

Anton Yartsev via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 28 09:28:57 PDT 2015


Author: ayartsev
Date: Wed Oct 28 11:28:57 2015
New Revision: 251524

URL: http://llvm.org/viewvc/llvm-project?rev=251524&view=rev
Log:
[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.

Modified:
    cfe/trunk/tools/scan-build/scan-build

Modified: cfe/trunk/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=251524&r1=251523&r2=251524&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Wed Oct 28 11:28:57 2015
@@ -54,8 +54,8 @@ my %Options = (
   ViewResults => 0,          # View results when the build terminates.
   ExitStatusFoundBugs => 0,  # Exit status reflects whether bugs were found
   KeepEmpty => 0,            # Don't remove output directory even with 0 results.
-  EnableCheckers => [],
-  DisableCheckers => [],
+  EnableCheckers => {},
+  DisableCheckers => {},
   UseCC => undef,            # C compiler to use for compilation.
   UseCXX => undef,           # C++ compiler to use for compilation.
   AnalyzerTarget => undef,
@@ -1630,13 +1630,17 @@ sub ProcessArgs {
 
     if ($arg eq "-enable-checker") {
       shift @$Args;
-      push @{$Options{EnableCheckers}}, shift @$Args;
+      my $Checker = shift @$Args;
+      $Options{EnableCheckers}{$Checker} = 1;
+      delete $Options{DisableCheckers}{$Checker};
       next;
     }
 
     if ($arg eq "-disable-checker") {
       shift @$Args;
-      push @{$Options{DisableCheckers}}, shift @$Args;
+      my $Checker = shift @$Args;
+      $Options{DisableCheckers}{$Checker} = 1;
+      delete $Options{EnableCheckers}{$Checker};
       next;
     }
 
@@ -1747,8 +1751,8 @@ Diag("Using '$Clang' for static analysis
 SetHtmlEnv(\@ARGV, $Options{OutputDir});
 
 my @AnalysesToRun;
-foreach (@{$Options{EnableCheckers}}) { push @AnalysesToRun, "-analyzer-checker", $_; }
-foreach (@{$Options{DisableCheckers}}) { push @AnalysesToRun, "-analyzer-disable-checker", $_; }
+foreach (keys %{$Options{EnableCheckers}}) { push @AnalysesToRun, "-analyzer-checker", $_; }
+foreach (keys %{$Options{DisableCheckers}}) { 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}"; }




More information about the cfe-commits mailing list