aboutsummaryrefslogtreecommitdiff
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
commit3bbdd87c88d710bfb3e96cd8eabfaf3079c3f696 (patch)
tree85d7f9fc747943f9b8b1406c9f8aead1ce454f76
parent99fcbf67d04d488d819bffb8fda3bb9d5504b63b (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 llvm-svn: 351232
-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 15fc086f8ade..d62a3513c777 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 88942ae6f893..89abe2a6e87b 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'?}}