aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-08-24 04:53:06 +0000
committerTed Kremenek <kremenek@apple.com>2012-08-24 04:53:06 +0000
commit56fd9084b11ee31fed996e4b58fc099284d1c8be (patch)
treee585c4ca784c774805abcfa73481bbec14cc9cf8
parent55dd956d521d4d650dfd929d67f4b98ede61c0ea (diff)
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> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162535 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xtools/scan-build/scan-build26
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index 65c4893124..e2efa44bc1 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -102,12 +102,26 @@ if (!defined $ClangSB || ! -x $ClangSB) {
$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 $CmdCXX || ! -x $CmdCXX) {
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);