[PATCH] D33258: clang-cl: Fix path-based MSVC version detection

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 14:13:02 PDT 2017


hans created this revision.

The code wasn't taking the architecture-specific subdirectory into account.


https://reviews.llvm.org/D33258

Files:
  lib/Driver/ToolChains/MSVC.cpp


Index: lib/Driver/ToolChains/MSVC.cpp
===================================================================
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -124,9 +124,19 @@
       if (!llvm::sys::fs::exists(ExeTestPath))
         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);
+      // Strip any architecture specific subdirectory.
+      llvm::StringRef TestPath = PathEntry;
+      if (llvm::sys::path::filename(TestPath) == "amd64" ||
+          llvm::sys::path::filename(TestPath) == "amd64_arm" ||
+          llvm::sys::path::filename(TestPath) == "amd64_x86" ||
+          llvm::sys::path::filename(TestPath) == "arm" ||
+          llvm::sys::path::filename(TestPath) == "x86_amd64" ||
+          llvm::sys::path::filename(TestPath) == "x86_arm")
+        TestPath = llvm::sys::path::parent_path(TestPath);
+
+      // whatever/VC/bin --> old toolchain, // VC dir is toolchain dir.
+      if (llvm::sys::path::filename(TestPath) == "bin") {
+        llvm::StringRef ParentPath = llvm::sys::path::parent_path(TestPath);
         if (llvm::sys::path::filename(ParentPath) == "VC") {
           Path = ParentPath;
           IsVS2017OrNewer = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33258.99194.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170516/1e07fc9f/attachment-0001.bin>


More information about the cfe-commits mailing list