@@ -85,22 +85,11 @@ getHighestNumericTupleInDirectory(llvm::vfs::FileSystem &VFS,
8585 return Highest;
8686}
8787
88- static bool getWindows10SDKVersionFromPath (
89- llvm::vfs::FileSystem &VFS, const std::string &SDKPath,
90- std::optional<llvm::StringRef> WinSdkVersion, std::string &SDKVersion) {
88+ static bool getWindows10SDKVersionFromPath (llvm::vfs::FileSystem &VFS,
89+ const std::string &SDKPath,
90+ std::string &SDKVersion) {
9191 llvm::SmallString<128 > IncludePath (SDKPath);
9292 llvm::sys::path::append (IncludePath, " Include" );
93-
94- if (WinSdkVersion) {
95- // Use the provided version, if it exists.
96- llvm::SmallString<128 > VersionIncludePath (IncludePath);
97- llvm::sys::path::append (VersionIncludePath, *WinSdkVersion);
98- if (VFS.exists (VersionIncludePath)) {
99- SDKVersion = *WinSdkVersion;
100- return true ;
101- }
102- }
103-
10493 SDKVersion = getHighestNumericTupleInDirectory (VFS, IncludePath);
10594 return !SDKVersion.empty ();
10695}
@@ -133,8 +122,7 @@ static bool getWindowsSDKDirViaCommandLine(
133122 if (!SDKVersion.empty ()) {
134123 Major = SDKVersion.getMajor ();
135124 Version = SDKVersion.getAsString ();
136- } else if (getWindows10SDKVersionFromPath (VFS, Path, WinSdkVersion,
137- Version)) {
125+ } else if (getWindows10SDKVersionFromPath (VFS, Path, Version)) {
138126 Major = 10 ;
139127 }
140128 return true ;
@@ -456,8 +444,14 @@ bool getWindowsSDKDir(vfs::FileSystem &VFS, std::optional<StringRef> WinSdkDir,
456444 return !WindowsSDKLibVersion.empty ();
457445 }
458446 if (Major == 10 ) {
459- if (!getWindows10SDKVersionFromPath (VFS, Path, WinSdkVersion,
460- WindowsSDKIncludeVersion))
447+ if (WinSdkVersion) {
448+ // Use the user-provided version as-is.
449+ WindowsSDKIncludeVersion = WinSdkVersion->str ();
450+ WindowsSDKLibVersion = WindowsSDKIncludeVersion;
451+ return true ;
452+ }
453+
454+ if (!getWindows10SDKVersionFromPath (VFS, Path, WindowsSDKIncludeVersion))
461455 return false ;
462456 WindowsSDKLibVersion = WindowsSDKIncludeVersion;
463457 return true ;
@@ -488,7 +482,13 @@ bool getUniversalCRTSdkDir(vfs::FileSystem &VFS,
488482 Path, nullptr ))
489483 return false ;
490484
491- return getWindows10SDKVersionFromPath (VFS, Path, WinSdkVersion, UCRTVersion);
485+ if (WinSdkVersion) {
486+ // Use the user-provided version as-is.
487+ UCRTVersion = WinSdkVersion->str ();
488+ return true ;
489+ }
490+
491+ return getWindows10SDKVersionFromPath (VFS, Path, UCRTVersion);
492492}
493493
494494bool findVCToolChainViaCommandLine (vfs::FileSystem &VFS,
0 commit comments