forked from OSchip/llvm-project
Move normalization of `\` in #includes from -fms-compatibility to -fms-extensions
Handling backslashes in include paths in the implementation isn't non-conforming. llvm-svn: 372999
This commit is contained in:
parent
e8f0613185
commit
adc1830187
|
@ -1785,20 +1785,23 @@ Optional<FileEntryRef> Preprocessor::LookupHeaderIncludeOrImport(
|
|||
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::HandleHeaderIncludeOrImport(
|
|||
// the path.
|
||||
ModuleMap::KnownHeader SuggestedModule;
|
||||
SourceLocation FilenameLoc = FilenameTok.getLocation();
|
||||
SmallString<128> NormalizedPath;
|
||||
if (LangOpts.MSVCCompat) {
|
||||
NormalizedPath = Filename.str();
|
||||
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.MicrosoftExt) {
|
||||
NormalizedPath = Filename.str();
|
||||
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,
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue