From: Volodymyr Sapsai Date: Tue, 15 Jan 2019 20:08:23 +0000 (+0000) Subject: [MSVC Compat] Fix typo correction for inclusion directives. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12233a4da079fa013f7460b1804005a3a5e31c32;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351232 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 15fc086f8a..d62a3513c7 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/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/test/Preprocessor/include-likely-typo.c b/test/Preprocessor/include-likely-typo.c index 88942ae6f8..89abe2a6e8 100644 --- a/test/Preprocessor/include-likely-typo.c +++ b/test/Preprocessor/include-likely-typo.c @@ -1,3 +1,4 @@ // RUN: %clang_cc1 %s -verify +// RUN: %clang_cc1 -fms-compatibility %s -verify #include "" // expected-error {{'' file not found, did you mean 'empty_file_to_include.h'?}}