Author: rnk Date: Thu Sep 26 10:19:22 2019 New Revision: 372999 URL: http://llvm.org/viewvc/llvm-project?rev=372999&view=rev Log: Move normalization of `\` in #includes from -fms-compatibility to -fms-extensions
Handling backslashes in include paths in the implementation isn't non-conforming. Modified: cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp cfe/trunk/test/Lexer/cross-windows-on-linux.cpp Modified: cfe/trunk/lib/Lex/PPDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=372999&r1=372998&r2=372999&view=diff ============================================================================== --- cfe/trunk/lib/Lex/PPDirectives.cpp (original) +++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Sep 26 10:19:22 2019 @@ -1785,20 +1785,23 @@ Optional<FileEntryRef> Preprocessor::Loo return Filename; }; StringRef TypoCorrectionName = CorrectTypoFilename(Filename); - SmallString<128> NormalizedTypoCorrectionPath; - if (LangOpts.MSVCCompat) { - NormalizedTypoCorrectionPath = TypoCorrectionName.str(); + #ifndef _WIN32 + // Normalize slashes when compiling with -fms-extensions on non-Windows. + // This is unnecessary on Windows since the filesystem there handles + // backslashes. + SmallString<128> NormalizedTypoCorrectionPath; + if (LangOpts.MicrosoftExt) { + NormalizedTypoCorrectionPath = TypoCorrectionName; llvm::sys::path::native(NormalizedTypoCorrectionPath); -#endif + TypoCorrectionName = NormalizedTypoCorrectionPath; } +#endif + Optional<FileEntryRef> File = LookupFile( - FilenameLoc, - LangOpts.MSVCCompat ? NormalizedTypoCorrectionPath.c_str() - : TypoCorrectionName, - isAngled, LookupFrom, LookupFromFile, CurDir, - Callbacks ? &SearchPath : nullptr, Callbacks ? &RelativePath : nullptr, - &SuggestedModule, &IsMapped, + FilenameLoc, TypoCorrectionName, isAngled, LookupFrom, LookupFromFile, + CurDir, Callbacks ? &SearchPath : nullptr, + Callbacks ? &RelativePath : nullptr, &SuggestedModule, &IsMapped, /*IsFrameworkFound=*/nullptr); if (File) { auto Hint = @@ -1906,15 +1909,18 @@ Preprocessor::ImportAction Preprocessor: // the path. ModuleMap::KnownHeader SuggestedModule; SourceLocation FilenameLoc = FilenameTok.getLocation(); + StringRef LookupFilename = Filename; + +#ifndef _WIN32 + // Normalize slashes when compiling with -fms-extensions on non-Windows. This + // is unnecessary on Windows since the filesystem there handles backslashes. SmallString<128> NormalizedPath; - if (LangOpts.MSVCCompat) { + if (LangOpts.MicrosoftExt) { NormalizedPath = Filename.str(); -#ifndef _WIN32 llvm::sys::path::native(NormalizedPath); -#endif + LookupFilename = NormalizedPath; } - StringRef LookupFilename = - LangOpts.MSVCCompat ? StringRef(NormalizedPath) : Filename; +#endif Optional<FileEntryRef> File = LookupHeaderIncludeOrImport( CurDir, Filename, FilenameLoc, FilenameRange, FilenameTok, Modified: cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp?rev=372999&r1=372998&r2=372999&view=diff ============================================================================== --- cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp (original) +++ cfe/trunk/test/Lexer/cross-windows-on-linux-default.cpp Thu Sep 26 10:19:22 2019 @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -fsyntax-only -fms-compatibility -triple i686-win32 %s 2>&1 \ +// RUN: not %clang_cc1 -fsyntax-only -fms-extensions -triple i686-win32 %s 2>&1 \ // RUN: | FileCheck %s #include "Inputs\success.h" Modified: cfe/trunk/test/Lexer/cross-windows-on-linux.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cross-windows-on-linux.cpp?rev=372999&r1=372998&r2=372999&view=diff ============================================================================== --- cfe/trunk/test/Lexer/cross-windows-on-linux.cpp (original) +++ cfe/trunk/test/Lexer/cross-windows-on-linux.cpp Thu Sep 26 10:19:22 2019 @@ -6,10 +6,8 @@ // CHECK: #include "Inputs\success.h" // CHECK: ^ -// expected to fail on windows as the inclusion would succeed and the -// compilation will fail due to the '#error success'. -// XFAIL: windows-msvc - -// This test may or may not fail since 'Inputs\success.h' is passed -// to Win32 APIs on Windows. -// REQUIRES: disabled +// This test is really checking that we *don't* replace backslashes with slashes +// on non-Windows unless -fms-extensions is passed. It won't fail in this way on +// Windows because the filesystem will interpret the backslash as a directory +// separator. +// UNSUPPORTED: system-windows _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits