[cfe-commits] r91172 - in /cfe/trunk/tools/scan-build: ccc-analyzer scan-build

Ted Kremenek kremenek at apple.com
Fri Dec 11 14:44:54 PST 2009


Author: kremenek
Date: Fri Dec 11 16:44:53 2009
New Revision: 91172

URL: http://llvm.org/viewvc/llvm-project?rev=91172&view=rev
Log:
Convert scan-build and ccc-analyzer over to using 'clang -cc1' instead of using 'clang-cc'.

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

Modified: cfe/trunk/tools/scan-build/ccc-analyzer
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/ccc-analyzer?rev=91172&r1=91171&r2=91172&view=diff

==============================================================================
--- cfe/trunk/tools/scan-build/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/ccc-analyzer Fri Dec 11 16:44:53 2009
@@ -53,7 +53,7 @@
 my $AttributeIgnored = "Attribute Ignored";
 
 sub ProcessClangFailure {
-  my ($ClangCC, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
+  my ($Clang, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
   my $Dir = "$HtmlDir/failures";
   mkpath $Dir;
   
@@ -69,7 +69,7 @@
   my ($PPH, $PPFile) = tempfile( $prefix . "_XXXXXX",
                                  SUFFIX => GetPPExt($Lang),
                                  DIR => $Dir);
-  system $ClangCC, @$Args, "-E", "-o", $PPFile;
+  system $Clang, @$Args, "-E", "-o", $PPFile;
   close ($PPH);
   
   # Create the info file.
@@ -129,7 +129,7 @@
 }
 
 sub Analyze {
-  my ($ClangCC, $Args, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
+  my ($Clang, $Args, $AnalyzeArgs, $Lang, $Output, $Verbose, $HtmlDir,
       $file, $Analyses) = @_;
   
   $Args = GetCCArgs($Args);
@@ -152,9 +152,10 @@
     @CmdArgsSansAnalyses = @CmdArgs;    
   }
   else {
-    $Cmd = $ClangCC;
+    $Cmd = $Clang;
+    push @CmdArgs, "-cc1";
     push @CmdArgs,'-DIBOutlet=__attribute__((iboutlet))';
-    push @CmdArgs,@$Args;
+    push @CmdArgs, @$Args;
     @CmdArgsSansAnalyses = @CmdArgs;
     push @CmdArgs,'-analyze';
     push @CmdArgs,"-analyzer-display-progress";
@@ -237,13 +238,13 @@
 
   # Did the command die because of a signal?
   if ($ReportFailures) {
-    if ($Result & 127 and $Cmd eq $ClangCC and defined $HtmlDir) {
-      ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses,
+    if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
+      ProcessClangFailure($Clang, $Lang, $file, \@CmdArgsSansAnalyses,
                           $HtmlDir, "Crash", $ofile);
     }
     elsif ($Result) {
       if ($IncludeParserRejects && !($file =~/conftest/)) {
-        ProcessClangFailure($ClangCC, $Lang, $file, \@CmdArgsSansAnalyses,
+        ProcessClangFailure($Clang, $Lang, $file, \@CmdArgsSansAnalyses,
                             $HtmlDir, $ParserRejects, $ofile);
       }
     }
@@ -275,7 +276,7 @@
           # Add this file to the list of files that contained this attribute.
           # Generate a preprocessed file if we haven't already.
           if (!(defined $ppfile)) {
-            $ppfile = ProcessClangFailure($ClangCC, $Lang, $file,
+            $ppfile = ProcessClangFailure($Clang, $Lang, $file,
                                           \@CmdArgsSansAnalyses,
                                           $HtmlDir, $AttributeIgnored, $ofile);
           }
@@ -400,10 +401,6 @@
 if (defined $ENV{CCC_ANALYZER_VERBOSE}) { $Verbose = 1; }
 if (defined $ENV{CCC_ANALYZER_LOG}) { $Verbose = 2; }
 
-# Determine what clang-cc executable to use.
-my $ClangCC = $ENV{'CLANG_CC'};
-if (!defined $ClangCC) { $ClangCC = 'clang-cc'; }
-
 # Get the HTML output directory.
 my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
 
@@ -618,12 +615,12 @@
         push @NewArgs, '-arch';
         push @NewArgs, $arch;
         push @NewArgs, @CmdArgs;
-        Analyze($ClangCC, \@NewArgs, \@AnalyzeArgs, $FileLang, $Output,
+        Analyze($Clang, \@NewArgs, \@AnalyzeArgs, $FileLang, $Output,
                 $Verbose, $HtmlDir, $file, $Analyses);
       }
     }
     else {
-      Analyze($ClangCC, \@CmdArgs, \@AnalyzeArgs, $FileLang, $Output,
+      Analyze($Clang, \@CmdArgs, \@AnalyzeArgs, $FileLang, $Output,
               $Verbose, $HtmlDir, $file, $Analyses);
     }
   }

Modified: cfe/trunk/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=91172&r1=91171&r2=91172&view=diff

==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Fri Dec 11 16:44:53 2009
@@ -81,43 +81,22 @@
 # Some initial preprocessing of Clang options.
 ##----------------------------------------------------------------------------##
 
-# First, look for 'clang-cc' in libexec.
-my $ClangCCSB = Cwd::realpath("$RealBin/libexec/clang-cc");
-# Second, look for 'clang-cc' in the same directory as scan-build.
-if (!defined $ClangCCSB || ! -x $ClangCCSB) {
-  $ClangCCSB = Cwd::realpath("$RealBin/clang-cc");
-}
-# Third, look for 'clang-cc' in ../libexec
-if (!defined $ClangCCSB || ! -x $ClangCCSB) {
-  $ClangCCSB = Cwd::realpath("$RealBin/../libexec/clang-cc");
-}
-# Finally, default to looking for 'clang-cc' in the path.
-if (!defined $ClangCCSB || ! -x $ClangCCSB) {
-  $ClangCCSB = "clang-cc";
-}
-my $ClangCC = $ClangCCSB;
-
-# Now find 'clang'
+# Find 'clang'
 my $ClangSB = Cwd::realpath("$RealBin/bin/clang");
 if (!defined $ClangSB || ! -x $ClangSB) {
   $ClangSB = Cwd::realpath("$RealBin/clang");
 }
-# Third, look for 'clang' in ../bin
-if (!defined $ClangSB || ! -x $ClangSB) {
-  $ClangSB = Cwd::realpath("$RealBin/../bin/clang");
-}
-# Finally, default to looking for 'clang-cc' in the path.
-if (!defined $ClangSB || ! -x $ClangSB) {
-  $ClangSB = "clang";
-}
 my $Clang = $ClangSB;
-
+# Default to looking for 'clang' in the path.
+if (!defined $Clang || ! -x $Clang) {
+  $Clang = "clang";
+}
 
 my %AvailableAnalyses;
 
 # Query clang for analysis options.
-open(PIPE, "-|", $ClangCC, "--help") or
-  DieDiag("Cannot execute '$ClangCC'\n");
+open(PIPE, "-|", $Clang, "-cc1", "--help") or
+  DieDiag("Cannot execute '$Clang'\n");
 
 my $FoundAnalysis = 0;
 
@@ -128,17 +107,14 @@
     }
     next;
   }
-    
   if (/^\s\s\s\s([^\s]+)\s(.+)$/) {
     next if ($1 =~ /-dump/ or $1 =~ /-view/ 
-             or $1 =~ /-warn-uninit/);
-             
+             or $1 =~ /-warn-uninit/);             
     $AvailableAnalyses{$1} = $2;
     next;
   }  
   last;
 }
-
 close (PIPE);
 
 my %AnalysesDefaultEnabled = (
@@ -156,10 +132,8 @@
 ##----------------------------------------------------------------------------##
 
 sub GetHTMLRunDir {  
-
   die "Not enough arguments." if (@_ == 0);  
-  my $Dir = shift @_;
-    
+  my $Dir = shift @_;    
   my $TmpMode = 0;
   if (!defined $Dir) {
     if (`uname` =~ /Darwin/) {
@@ -168,8 +142,7 @@
     }
     else {
       $Dir = "/tmp";
-    }
-    
+    }    
     $TmpMode = 1;
   }
   
@@ -177,42 +150,32 @@
   while ($Dir =~ /\/$/) { chop $Dir; }
 
   # Get current date and time.
-  
-  my @CurrentTime = localtime();
-  
+  my @CurrentTime = localtime();  
   my $year  = $CurrentTime[5] + 1900;
   my $day   = $CurrentTime[3];
   my $month = $CurrentTime[4] + 1;
-  
   my $DateString = sprintf("%d-%02d-%02d", $year, $month, $day);
   
-  # Determine the run number.
-  
+  # Determine the run number.  
   my $RunNumber;
   
-  if (-d $Dir) {
-    
+  if (-d $Dir) {    
     if (! -r $Dir) {
       DieDiag("directory '$Dir' exists but is not readable.\n");
-    }
-    
-    # Iterate over all files in the specified directory.
-    
-    my $max = 0;
-    
+    }    
+    # Iterate over all files in the specified directory.    
+    my $max = 0;    
     opendir(DIR, $Dir);
     my @FILES = grep { -d "$Dir/$_" } readdir(DIR);
     closedir(DIR);
-    
-    foreach my $f (@FILES) {
 
+    foreach my $f (@FILES) {
       # Strip the prefix '$Prog-' if we are dumping files to /tmp.
       if ($TmpMode) {
         next if (!($f =~ /^$Prog-(.+)/));
         $f = $1;
       }
 
-      
       my @x = split/-/, $f;
       next if (scalar(@x) != 4);
       next if ($x[0] != $year);
@@ -1212,10 +1175,6 @@
   DieDiag("Executable 'ccc-analyzer' does not exist at '$Cmd'\n") if(! -x $Cmd);
 }
 
-if (!defined $ClangCCSB || ! -x $ClangCCSB) {
-  Diag("'clang-cc' executable not found in '$RealBin/libexec'.\n");
-  Diag("Using 'clang-cc' from path.\n");
-}
 if (!defined $ClangSB || ! -x $ClangSB) {
   Diag("'clang' executable not found in '$RealBin/bin'.\n");
   Diag("Using 'clang' from path.\n");
@@ -1230,7 +1189,6 @@
 }
   
 $ENV{'CC'} = $Cmd;
-$ENV{'CLANG_CC'} = $ClangCC;
 $ENV{'CLANG'} = $Clang;
 
 if ($Verbose >= 2) {





More information about the cfe-commits mailing list