[PATCH] D59406: [analyzer] Teach scan-build to find /usr/bin/clang when installed in /usr/local/bin/
Devin Coughlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 18:00:48 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356308: [analyzer] Teach scan-build to find clang when installed in /usr/local/bin/ (authored by dcoughlin, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D59406?vs=190931&id=190932#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59406/new/
https://reviews.llvm.org/D59406
Files:
cfe/trunk/tools/scan-build/bin/scan-build
Index: cfe/trunk/tools/scan-build/bin/scan-build
===================================================================
--- cfe/trunk/tools/scan-build/bin/scan-build
+++ cfe/trunk/tools/scan-build/bin/scan-build
@@ -1460,6 +1460,16 @@
}
##----------------------------------------------------------------------------##
+# 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 @@
$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 @@
}
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";
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59406.190932.patch
Type: text/x-patch
Size: 1922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190316/ca662503/attachment.bin>
More information about the llvm-commits
mailing list