From: Hans Wennborg Date: Wed, 17 May 2017 15:27:44 +0000 (+0000) Subject: clang-cl: Fix path-based MSVC version detection X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4df3e3e59080c80f05a1a4aac88d59411516fda;p=clang 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 --- diff --git a/lib/Driver/ToolChains/MSVC.cpp b/lib/Driver/ToolChains/MSVC.cpp index a09304814c..6f5f54165b 100644 --- a/lib/Driver/ToolChains/MSVC.cpp +++ b/lib/Driver/ToolChains/MSVC.cpp @@ -125,8 +125,15 @@ static bool findVCToolChainViaEnvironment(std::string &Path, continue; // whatever/VC/bin --> old toolchain, VC dir is toolchain dir. - if (llvm::sys::path::filename(PathEntry) == "bin") { - llvm::StringRef ParentPath = llvm::sys::path::parent_path(PathEntry); + llvm::StringRef TestPath = PathEntry; + bool IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin"); + if (!IsBin) { + // Strip any architecture subdir like "amd64". + TestPath = llvm::sys::path::parent_path(TestPath); + IsBin = llvm::sys::path::filename(TestPath).equals_lower("bin"); + } + if (IsBin) { + llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath); if (llvm::sys::path::filename(ParentPath) == "VC") { Path = ParentPath; IsVS2017OrNewer = false;