[cfe-commits] r127428 - /cfe/trunk/tools/scan-build/ccc-analyzer

Ted Kremenek kremenek at apple.com
Thu Mar 10 13:10:08 PST 2011


Author: kremenek
Date: Thu Mar 10 15:10:08 2011
New Revision: 127428

URL: http://llvm.org/viewvc/llvm-project?rev=127428&view=rev
Log:
Tweak ccc-analyzer's 'Analyze' function to not mutate the original arguments list.

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

Modified: cfe/trunk/tools/scan-build/ccc-analyzer
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/ccc-analyzer?rev=127428&r1=127427&r2=127428&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/ccc-analyzer Thu Mar 10 15:10:08 2011
@@ -147,9 +147,10 @@
 }
 
 sub Analyze {
-  my ($Clang, $Args, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
+  my ($Clang, $OriginalArgs, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
       $file) = @_;
 
+  my @Args = @$OriginalArgs;
   my $Cmd;
   my @CmdArgs;
   my @CmdArgsSansAnalyses;
@@ -166,41 +167,40 @@
   else {
     $Cmd = $Clang;
     if ($Lang eq "objective-c" || $Lang eq "objective-c++") {
-      push @$Args,'-DIBOutlet=__attribute__((iboutlet))';
-      push @$Args,'-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection)))';
-      push @$Args,'-DIBAction=void)__attribute__((ibaction)';
+      push @Args,'-DIBOutlet=__attribute__((iboutlet))';
+      push @Args,'-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection)))';
+      push @Args,'-DIBAction=void)__attribute__((ibaction)';
     }
 
     # Create arguments for doing regular parsing.
-    my $SyntaxArgs = GetCCArgs("-fsyntax-only", $Args);
-    @CmdArgsSansAnalyses = @CmdArgs;    
-    push @CmdArgsSansAnalyses, @$SyntaxArgs;
-    
+    my $SyntaxArgs = GetCCArgs("-fsyntax-only", \@Args);
+    @CmdArgsSansAnalyses = @$SyntaxArgs;
+
     # Create arguments for doing static analysis.
     if (defined $ResultFile) {
-      push @$Args,'-o';
-      push @$Args, $ResultFile;
+      push @Args,'-o';
+      push @Args, $ResultFile;
     }
     elsif (defined $HtmlDir) {
-      push @$Args,'-o';
-      push @$Args, $HtmlDir;
+      push @Args,'-o';
+      push @Args, $HtmlDir;
     }
-    push @$Args,"-Xclang";
-    push @$Args,"-analyzer-display-progress";
+    push @Args,"-Xclang";
+    push @Args,"-analyzer-display-progress";
 
     foreach my $arg (@$AnalyzeArgs) {
-      push @$Args, "-Xclang";
-      push @$Args, $arg;
+      push @Args, "-Xclang";
+      push @Args, $arg;
     }
     
     # Display Ubiviz graph?
     if (defined $ENV{'CCC_UBI'}) {   
-      push @$Args, "-Xclang";
-      push @$Args,"-analyzer-viz-egraph-ubigraph";
+      push @Args, "-Xclang";
+      push @Args,"-analyzer-viz-egraph-ubigraph";
     }
 
-    my $AnalysisArgs = GetCCArgs("--analyze", $Args);
-    push @CmdArgs, @$AnalysisArgs;
+    my $AnalysisArgs = GetCCArgs("--analyze", \@Args);
+    @CmdArgs = @$AnalysisArgs;
   }
 
   my @PrintArgs;
@@ -217,7 +217,7 @@
   if ($Verbose == 1) {
     # We MUST print to stderr.  Some clients use the stdout output of
     # gcc for various purposes. 
-    print STDERR join(' ', at PrintArgs);
+    print STDERR join(' ', @PrintArgs);
     print STDERR "\n";
   }
   elsif ($Verbose == 2) {





More information about the cfe-commits mailing list