[clang] 7a5184e - [scan-build] Fix clang++ pathname again
Stephan Bergmann via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 23:17:56 PST 2020
Author: Stephan Bergmann
Date: 2020-11-03T08:17:17+01:00
New Revision: 7a5184ed951ad38d652d7b3c339f4c6ae7842eeb
URL: https://github.com/llvm/llvm-project/commit/7a5184ed951ad38d652d7b3c339f4c6ae7842eeb
DIFF: https://github.com/llvm/llvm-project/commit/7a5184ed951ad38d652d7b3c339f4c6ae7842eeb.diff
LOG: [scan-build] Fix clang++ pathname again
e00629f777d9d62875730f40d266727df300dbb2 "[scan-build] Fix clang++ pathname" had
removed the -MAJOR.MINOR suffix, but since presumably LLVM 7 the suffix is only
-MAJOR, so ClangCXX (i.e., the CLANG_CXX environment variable passed to
clang/tools/scan-build/libexec/ccc-analyzer) now contained a non-existing
/path/to/clang-12++ (which apparently went largely unnoticed as
clang/tools/scan-build/libexec/ccc-analyzer falls back to just 'clang++' if the
executable denoted by CLANG_CXX does not exist).
For the new clang/test/Analysis/scan-build/cxx-name.test to be effective,
%scan-build must now take care to pass the clang executable's resolved pathname
(i.e., ending in .../clang-MAJOR rather than just .../clang) to --use-analyzer.
Differential Revision: https://reviews.llvm.org/D89481
Added:
clang/test/Analysis/scan-build/cxx-name.test
Modified:
clang/test/Analysis/scan-build/lit.local.cfg
clang/tools/scan-build/bin/scan-build
Removed:
################################################################################
diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test
new file mode 100644
index 000000000000..483762d619d1
--- /dev/null
+++ b/clang/test/Analysis/scan-build/cxx-name.test
@@ -0,0 +1,9 @@
+REQUIRES: shell
+
+RUN: %scan-build sh -c 'echo "CLANG_CXX=/$(basename "$CLANG_CXX")/"' | FileCheck %s
+
+Check that scan-build sets the CLANG_CXX environment variable (meant to be
+consumed by ccc-analyzer) to an appropriate pathname for the clang++ executable,
+derived from the pathname of the clang executable:
+
+CHECK: CLANG_CXX=/clang++{{(\.exe)?}}/
diff --git a/clang/test/Analysis/scan-build/lit.local.cfg b/clang/test/Analysis/scan-build/lit.local.cfg
index b4e097d4bab9..09ed92171478 100644
--- a/clang/test/Analysis/scan-build/lit.local.cfg
+++ b/clang/test/Analysis/scan-build/lit.local.cfg
@@ -15,4 +15,4 @@ config.substitutions.append(('%scan-build',
'tools',
'scan-build',
'bin')),
- config.clang)))
+ os.path.realpath(config.clang))))
diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build
index aed8c417b6cc..645f5507b6fa 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -1925,7 +1925,7 @@ if ($Clang !~ /\+\+(\.exe)?$/) {
$ClangCXX =~ s/.exe$/++.exe/;
}
else {
- $ClangCXX =~ s/\-\d+\.\d+$//;
+ $ClangCXX =~ s/\-\d+(\.\d+)?$//;
$ClangCXX .= "++";
}
}
More information about the cfe-commits
mailing list