[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
This commit is contained in:
Volodymyr Sapsai 2019-01-15 20:08:23 +00:00
parent 99fcbf67d0
commit 3bbdd87c88
2 changed files with 10 additions and 1 deletions

View 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);

View 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'?}}