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>

llvm-svn: 162535
This commit is contained in:
Ted Kremenek 2012-08-24 04:53:06 +00:00
parent 663d160adb
commit af592eef7b
1 changed files with 20 additions and 6 deletions

View File

@ -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);