Merge pull request #15148 from compnerd/msvc-sdk
diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp
index d8cc57d..ae49fb1 100644
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -563,14 +563,21 @@
invocationArgStrs.push_back("-Xclang");
invocationArgStrs.push_back("-nostdsysteminc");
} else {
- // On Darwin, Clang uses -isysroot to specify the include
- // system root. On other targets, it seems to use --sysroot.
- if (triple.isOSDarwin()) {
- invocationArgStrs.push_back("-isysroot");
+ if (triple.isWindowsMSVCEnvironment()) {
+ llvm::SmallString<261> path; // MAX_PATH + 1
+ path = searchPathOpts.SDKPath;
+ llvm::sys::path::append(path, "usr", "include");
+ llvm::sys::path::native(path);
+
+ invocationArgStrs.push_back("-isystem");
+ invocationArgStrs.push_back(path.str());
} else {
- invocationArgStrs.push_back("--sysroot");
+ // On Darwin, Clang uses -isysroot to specify the include
+ // system root. On other targets, it seems to use --sysroot.
+ invocationArgStrs.push_back(triple.isOSDarwin() ? "-isysroot"
+ : "--sysroot");
+ invocationArgStrs.push_back(searchPathOpts.SDKPath);
}
- invocationArgStrs.push_back(searchPathOpts.SDKPath);
}
const std::string &moduleCachePath = importerOpts.ModuleCachePath;