Author: vsapsai Date: Tue Jan 15 12:08:23 2019 New Revision: 351232 URL: http://llvm.org/viewvc/llvm-project?rev=351232&view=rev Log: [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 Modified: cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/test/Preprocessor/include-likely-typo.c Modified: cfe/trunk/lib/Lex/PPDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=351232&r1=351231&r2=351232&view=diff ============================================================================== --- cfe/trunk/lib/Lex/PPDirectives.cpp (original) +++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Jan 15 12:08:23 2019 @@ -1813,9 +1813,17 @@ void Preprocessor::HandleIncludeDirectiv 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); Modified: cfe/trunk/test/Preprocessor/include-likely-typo.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/include-likely-typo.c?rev=351232&r1=351231&r2=351232&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/include-likely-typo.c (original) +++ cfe/trunk/test/Preprocessor/include-likely-typo.c Tue Jan 15 12:08:23 2019 @@ -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'?}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits