[cfe-commits] r162535 - /cfe/trunk/tools/scan-build/scan-build

Ted Kremenek kremenek at apple.com
Thu Aug 23 21:53:07 PDT 2012


Author: kremenek
Date: Thu Aug 23 23:53:06 2012
New Revision: 162535

URL: http://llvm.org/viewvc/llvm-project?rev=162535&view=rev
Log:
On OS X, use xcrun (if present) to find the clang to use for static analysis if
no clang can be found relative to the location of scan-build.

Fixes <rdar://problem/11691794>

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=162535&r1=162534&r2=162535&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Thu Aug 23 23:53:06 2012
@@ -102,12 +102,26 @@
   $ClangSB = Cwd::realpath("$RealBin/clang");
 }
 my $Clang;
+my $howFound = "from path";
 if (!defined $ClangSB || ! -x $ClangSB) {
-  # Default to looking for 'clang' in the path.
-  $Clang = `which clang`;
-  chomp $Clang;
-  if ($Clang eq "") {
-    DieDiag("No 'clang' executable found in path.\n");
+  # Default to looking for 'clang' in the path, or xcrun
+  # on OS X.
+  my $xcrun = `which xcrun`;
+  chomp $xcrun;
+  if ($xcrun ne "") {
+    $Clang = `$xcrun -toolchain XcodeDefault -find clang`;
+    chomp $Clang;  
+    if ($Clang eq "") {
+      DieDiag("No 'clang' executable found by 'xcrun'\n");
+    }
+    $howFound = "found using 'xcrun'";
+  }
+  else {
+    $Clang = `which clang`;
+    chomp $Clang;
+    if ($Clang eq "") {
+      DieDiag("No 'clang' executable found in path\n");
+    }
   }
 }
 else {
@@ -1459,7 +1473,7 @@
 
 if (!defined $ClangSB || ! -x $ClangSB) {
   Diag("'clang' executable not found in '$RealBin/bin'.\n");
-  Diag("Using 'clang' from path: $Clang\n");
+  Diag("Using 'clang' $howFound: $Clang\n");
 }
 
 SetHtmlEnv(\@ARGV, $HtmlDir);





More information about the cfe-commits mailing list