Move normalization of `\` in #includes from -fms-compatibility to -fms-extensions
Handling backslashes in include paths in the implementation isn't
non-conforming.
llvm-svn: 372999
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 660aba1..3b7eaee 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1785,20 +1785,23 @@
return Filename;
};
StringRef TypoCorrectionName = CorrectTypoFilename(Filename);
- SmallString<128> NormalizedTypoCorrectionPath;
- if (LangOpts.MSVCCompat) {
- NormalizedTypoCorrectionPath = TypoCorrectionName.str();
+
#ifndef _WIN32
+ // Normalize slashes when compiling with -fms-extensions on non-Windows.
+ // This is unnecessary on Windows since the filesystem there handles
+ // backslashes.
+ SmallString<128> NormalizedTypoCorrectionPath;
+ if (LangOpts.MicrosoftExt) {
+ NormalizedTypoCorrectionPath = TypoCorrectionName;
llvm::sys::path::native(NormalizedTypoCorrectionPath);
-#endif
+ TypoCorrectionName = NormalizedTypoCorrectionPath;
}
+#endif
+
Optional<FileEntryRef> File = LookupFile(
- FilenameLoc,
- LangOpts.MSVCCompat ? NormalizedTypoCorrectionPath.c_str()
- : TypoCorrectionName,
- isAngled, LookupFrom, LookupFromFile, CurDir,
- Callbacks ? &SearchPath : nullptr, Callbacks ? &RelativePath : nullptr,
- &SuggestedModule, &IsMapped,
+ FilenameLoc, TypoCorrectionName, isAngled, LookupFrom, LookupFromFile,
+ CurDir, Callbacks ? &SearchPath : nullptr,
+ Callbacks ? &RelativePath : nullptr, &SuggestedModule, &IsMapped,
/*IsFrameworkFound=*/nullptr);
if (File) {
auto Hint =
@@ -1906,15 +1909,18 @@
// the path.
ModuleMap::KnownHeader SuggestedModule;
SourceLocation FilenameLoc = FilenameTok.getLocation();
- SmallString<128> NormalizedPath;
- if (LangOpts.MSVCCompat) {
- NormalizedPath = Filename.str();
+ StringRef LookupFilename = Filename;
+
#ifndef _WIN32
+ // Normalize slashes when compiling with -fms-extensions on non-Windows. This
+ // is unnecessary on Windows since the filesystem there handles backslashes.
+ SmallString<128> NormalizedPath;
+ if (LangOpts.MicrosoftExt) {
+ NormalizedPath = Filename.str();
llvm::sys::path::native(NormalizedPath);
-#endif
+ LookupFilename = NormalizedPath;
}
- StringRef LookupFilename =
- LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename;
+#endif
Optional<FileEntryRef> File = LookupHeaderIncludeOrImport(
CurDir, Filename, FilenameLoc, FilenameRange, FilenameTok,