summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2019-01-15 20:08:23 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2019-01-15 20:08:23 +0000
commitb668c249a3e5ddcf0324e6bc7d1947720949778a (patch)
tree4ec410941a87f217872da4eb86610c499ffca227
parentd6e22d762b24bde4ace93838d038f983cc247de5 (diff)
[MSVC Compat] Fix typo correction for inclusion directives.
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
-rw-r--r--clang/lib/Lex/PPDirectives.cpp10
-rw-r--r--clang/test/Preprocessor/include-likely-typo.c1
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 15fc086f8ad..d62a3513c77 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -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);
diff --git a/clang/test/Preprocessor/include-likely-typo.c b/clang/test/Preprocessor/include-likely-typo.c
index 88942ae6f89..89abe2a6e87 100644
--- a/clang/test/Preprocessor/include-likely-typo.c
+++ b/clang/test/Preprocessor/include-likely-typo.c
@@ -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'?}}