[PATCH] D59406: [analyzer] Teach scan-build to find /usr/bin/clang when installed in /usr/local/bin/

Devin Coughlin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 21:30:50 PDT 2019

dcoughlin created this revision.
dcoughlin added a reviewer: NoQ.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Change scan-build to support the scenario where scan-build is installed in
/usr/local/bin/ but clang itself is installed in /usr/bin/.


  rC Clang



Index: tools/scan-build/bin/scan-build
--- tools/scan-build/bin/scan-build
+++ tools/scan-build/bin/scan-build
@@ -1468,6 +1468,13 @@
     $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) {
+        # Look for a clang in the sibling bin of the parent of the bin directory. So
+        # if scan-build is at /usr/local/bin/scan-build look for clang at /usr/bin/clang
+        if (-f "$RealBin/../../bin/clang") {
+          $Clang = Cwd::realpath("$RealBin/../../bin/clang");
+        }
+      }
     if (!defined $Clang || ! -x $Clang) {
       return "error: Cannot find an executable 'clang' relative to" .

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59406.190784.patch
Type: text/x-patch
Size: 870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190315/8669ee90/attachment-0001.bin>

More information about the cfe-commits mailing list