diff options
| author | Devin Coughlin <dcoughlin@apple.com> | 2019-03-16 01:01:29 +0000 |
|---|---|---|
| committer | Devin Coughlin <dcoughlin@apple.com> | 2019-03-16 01:01:29 +0000 |
| commit | a61641ef4009e113fd74eaaf8966aacf1eba2924 (patch) | |
| tree | 5c86e43aa02ef8117e86611e4c146d4fa93e0aa4 /clang | |
| parent | 49e978f780a56159381e36cbee5e7a9f076dfec3 (diff) | |
| download | bcm5719-llvm-a61641ef4009e113fd74eaaf8966aacf1eba2924.tar.gz bcm5719-llvm-a61641ef4009e113fd74eaaf8966aacf1eba2924.zip | |
[analyzer] Teach scan-build to find clang when installed in /usr/local/bin/
Change scan-build to support the scenario where scan-build is installed in
$TOOLCHAIN/usr/local/bin/ but clang itself is installed in $TOOLCHAIN/usr/bin/.
This is restricted to when 'xcrun' is present; that is, on the Mac.
rdar://problem/48914634
Differential Revision: https://reviews.llvm.org/D59406
llvm-svn: 356308
Diffstat (limited to 'clang')
| -rwxr-xr-x | clang/tools/scan-build/bin/scan-build | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build index ed68b3b5a4e..903e19a2909 100755 --- a/clang/tools/scan-build/bin/scan-build +++ b/clang/tools/scan-build/bin/scan-build @@ -1460,6 +1460,16 @@ sub ShellEscape { } ##----------------------------------------------------------------------------## +# FindXcrun - searches for the 'xcrun' executable. Returns "" if not found. +##----------------------------------------------------------------------------## + +sub FindXcrun { + my $xcrun = `which xcrun`; + chomp $xcrun; + return $xcrun; +} + +##----------------------------------------------------------------------------## # FindClang - searches for 'clang' executable. ##----------------------------------------------------------------------------## @@ -1468,6 +1478,16 @@ sub FindClang { $Clang = Cwd::realpath("$RealBin/bin/clang") if (-f "$RealBin/bin/clang"); if (!defined $Clang || ! -x $Clang) { $Clang = Cwd::realpath("$RealBin/clang") if (-f "$RealBin/clang"); + if (!defined $Clang || ! -x $Clang) { + # When an Xcode toolchain is present, look for a clang in the sibling bin + # of the parent of the bin directory. So if scan-build is at + # $TOOLCHAIN/usr/local/bin/scan-build look for clang at + # $TOOLCHAIN/usr/bin/clang. + my $has_xcode_toolchain = FindXcrun() ne ""; + if ($has_xcode_toolchain && -f "$RealBin/../../bin/clang") { + $Clang = Cwd::realpath("$RealBin/../../bin/clang"); + } + } } if (!defined $Clang || ! -x $Clang) { return "error: Cannot find an executable 'clang' relative to" . @@ -1477,8 +1497,7 @@ sub FindClang { } else { if ($Options{AnalyzerDiscoveryMethod} =~ /^[Xx]code$/) { - my $xcrun = `which xcrun`; - chomp $xcrun; + my $xcrun = FindXcrun(); if ($xcrun eq "") { return "Cannot find 'xcrun' to find 'clang' for analysis.\n"; } |

