Skip to content

Commit d4df3e3

Browse files
committed
clang-cl: Fix path-based MSVC version detection
The code wasn't taking the architecture-specific subdirectory into account. Differential Revision: https://reviews.llvm.org/D33258 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303267 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 816bdf0 commit d4df3e3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Driver/ToolChains/MSVC.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,15 @@ static bool findVCToolChainViaEnvironment(std::string &Path,
125125
continue;
126126

127127
// whatever/VC/bin --> old toolchain, VC dir is toolchain dir.
128-
if (llvm::sys::path::filename(PathEntry) == "bin") {
129-
llvm::StringRef ParentPath = llvm::sys::path::parent_path(PathEntry);
128+
llvm::StringRef TestPath = PathEntry;
129+
bool IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
130+
if (!IsBin) {
131+
// Strip any architecture subdir like "amd64".
132+
TestPath = llvm::sys::path::parent_path(TestPath);
133+
IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin");
134+
}
135+
if (IsBin) {
136+
llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
130137
if (llvm::sys::path::filename(ParentPath) == "VC") {
131138
Path = ParentPath;
132139
IsVS2017OrNewer = false;

0 commit comments

Comments
 (0)