]> granicus.if.org Git - clang/commitdiff
[MSVC Compat] Fix typo correction for inclusion directives.
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 15 Jan 2019 20:08:23 +0000 (20:08 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Tue, 15 Jan 2019 20:08:23 +0000 (20:08 +0000)
In MSVC compatibility mode we were checking not the typo corrected
filename but the original filename.

Reviewers: christylee, compnerd

Reviewed By: christylee

Subscribers: jkorous, dexonsmith, sammccall, hokein, cfe-commits

Differential Revision: https://reviews.llvm.org/D56631

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351232 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPDirectives.cpp
test/Preprocessor/include-likely-typo.c

index 15fc086f8adef9ad825a0feab4a9a88d7ca95fbd..d62a3513c777025d8a3e9199ca3bb114059d9007 100644 (file)
@@ -1813,9 +1813,17 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
           return Filename;
         };
         StringRef TypoCorrectionName = CorrectTypoFilename(Filename);
+        SmallString<128> NormalizedTypoCorrectionPath;
+        if (LangOpts.MSVCCompat) {
+          NormalizedTypoCorrectionPath = TypoCorrectionName.str();
+#ifndef _WIN32
+          llvm::sys::path::native(NormalizedTypoCorrectionPath);
+#endif
+        }
         File = LookupFile(
             FilenameLoc,
-            LangOpts.MSVCCompat ? NormalizedPath.c_str() : TypoCorrectionName,
+            LangOpts.MSVCCompat ? NormalizedTypoCorrectionPath.c_str()
+                                : TypoCorrectionName,
             isAngled, LookupFrom, LookupFromFile, CurDir,
             Callbacks ? &SearchPath : nullptr,
             Callbacks ? &RelativePath : nullptr, &SuggestedModule, &IsMapped);
index 88942ae6f8930eb33c9deb6bf571b68b84aaabcc..89abe2a6e87b26456814f6762d6e8d86fa6465bf 100644 (file)
@@ -1,3 +1,4 @@
 // RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 -fms-compatibility %s -verify
 
 #include "<empty_file_to_include.h>" // expected-error {{'<empty_file_to_include.h>' file not found, did you mean 'empty_file_to_include.h'?}}