diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 18 | ||||
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 8 |
4 files changed, 21 insertions, 24 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index c4eae6a..1cb52d5 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -123,16 +123,16 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) { DirName != llvm::sys::path::root_path(DirName) && llvm::sys::path::is_separator(DirName.back())) DirName = DirName.substr(0, DirName.size()-1); -#ifdef _WIN32 - // Fixing a problem with "clang C:test.c" on Windows. - // Stat("C:") does not recognize "C:" as a valid directory - std::string DirNameStr; - if (DirName.size() > 1 && DirName.back() == ':' && - DirName.equals_insensitive(llvm::sys::path::root_name(DirName))) { - DirNameStr = DirName.str() + '.'; - DirName = DirNameStr; + if (is_style_windows(llvm::sys::path::Style::native)) { + // Fixing a problem with "clang C:test.c" on Windows. + // Stat("C:") does not recognize "C:" as a valid directory + std::string DirNameStr; + if (DirName.size() > 1 && DirName.back() == ':' && + DirName.equals_insensitive(llvm::sys::path::root_name(DirName))) { + DirNameStr = DirName.str() + '.'; + DirName = DirNameStr; + } } -#endif ++NumDirLookups; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b64ca8..2ddb753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4899,11 +4899,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, bool MultipleArchs, StringRef OffloadingPrefix) const { std::string BoundArch = OrigBoundArch.str(); -#if defined(_WIN32) - // BoundArch may contains ':', which is invalid in file names on Windows, - // therefore replace it with '%'. - std::replace(BoundArch.begin(), BoundArch.end(), ':', '@'); -#endif + if (is_style_windows(llvm::sys::path::Style::native)) { + // BoundArch may contains ':', which is invalid in file names on Windows, + // therefore replace it with '%'. + std::replace(BoundArch.begin(), BoundArch.end(), ':', '@'); + } llvm::PrettyStackTraceString CrashInfo("Computing output path"); // Output to a user requested destination? diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index df205c3..debaf9e 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -169,10 +169,11 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { /// present and lower-casing the string on Windows. static std::string normalizeProgramName(llvm::StringRef Argv0) { std::string ProgName = std::string(llvm::sys::path::stem(Argv0)); -#ifdef _WIN32 - // Transform to lowercase for case insensitive file systems. - std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), ::tolower); -#endif + if (is_style_windows(llvm::sys::path::Style::native)) { + // Transform to lowercase for case insensitive file systems. + std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(), + ::tolower); + } return ProgName; } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index ea14921..1c2439a 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2012,20 +2012,16 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport( SourceLocation FilenameLoc = FilenameTok.getLocation(); StringRef LookupFilename = Filename; -#ifdef _WIN32 - llvm::sys::path::Style BackslashStyle = llvm::sys::path::Style::windows; -#else // Normalize slashes when compiling with -fms-extensions on non-Windows. This // is unnecessary on Windows since the filesystem there handles backslashes. SmallString<128> NormalizedPath; - llvm::sys::path::Style BackslashStyle = llvm::sys::path::Style::posix; - if (LangOpts.MicrosoftExt) { + llvm::sys::path::Style BackslashStyle = llvm::sys::path::Style::native; + if (is_style_posix(BackslashStyle) && LangOpts.MicrosoftExt) { NormalizedPath = Filename.str(); llvm::sys::path::native(NormalizedPath); LookupFilename = NormalizedPath; BackslashStyle = llvm::sys::path::Style::windows; } -#endif Optional<FileEntryRef> File = LookupHeaderIncludeOrImport( CurDir, Filename, FilenameLoc, FilenameRange, FilenameTok, |