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

llvm-svn: 303267
This commit is contained in:
Hans Wennborg 2017-05-17 15:27:44 +00:00
parent 3b57da0c73
commit 6dc120a41d
1 changed files with 9 additions and 2 deletions

View File

@ -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;