diff options
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Frontend/InitHeaderSearch.cpp | 38 |
2 files changed, 24 insertions, 19 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 0c6ab4a0bd8..4037af9055d 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -21,8 +21,8 @@ #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringSet.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PathV1.h" #include "llvm/Support/raw_ostream.h" using namespace clang; @@ -166,7 +166,8 @@ static void PrintFilename(raw_ostream &OS, StringRef Filename) { void DependencyFileCallback::OutputDependencyFile() { if (SeenMissingHeader) { - llvm::sys::Path(OutputFile).eraseFromDisk(); + bool existed; + llvm::sys::fs::remove(OutputFile, existed); return; } diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp index 46694d985df..3691adf3b9f 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -26,7 +26,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PathV1.h" #include "llvm/Support/raw_ostream.h" using namespace clang; @@ -245,8 +244,8 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, if (HSOpts.UseBuiltinIncludes) { // Ignore the sys root, we *always* look for clang headers relative to // supplied path. - llvm::sys::Path P(HSOpts.ResourceDir); - P.appendComponent("include"); + SmallString<128> P = StringRef(HSOpts.ResourceDir); + llvm::sys::path::append(P, "include"); AddUnmappedPath(P.str(), ExternCSystem, false); } @@ -313,15 +312,20 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, break; case llvm::Triple::MinGW32: { // mingw-w64 crt include paths - llvm::sys::Path P(HSOpts.ResourceDir); - P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include + // <sysroot>/i686-w64-mingw32/include + SmallString<128> P = StringRef(HSOpts.ResourceDir); + llvm::sys::path::append(P, "../../../i686-w64-mingw32/include"); AddPath(P.str(), System, false); - P = llvm::sys::Path(HSOpts.ResourceDir); - P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include + + // <sysroot>/x86_64-w64-mingw32/include + P.resize(HSOpts.ResourceDir.size()); + llvm::sys::path::append(P, "../../../x86_64-w64-mingw32/include"); AddPath(P.str(), System, false); + // mingw.org crt include paths - P = llvm::sys::Path(HSOpts.ResourceDir); - P.appendComponent("../../../include"); // <sysroot>/include + // <sysroot>/include + P.resize(HSOpts.ResourceDir.size()); + llvm::sys::path::append(P, "../../../include"); AddPath(P.str(), System, false); AddPath("/mingw/include", System, false); #if defined(_WIN32) @@ -470,14 +474,14 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, if (triple.isOSDarwin()) { // On Darwin, libc++ may be installed alongside the compiler in // lib/c++/v1. - llvm::sys::Path P(HSOpts.ResourceDir); - if (!P.isEmpty()) { - P.eraseComponent(); // Remove version from foo/lib/clang/version - P.eraseComponent(); // Remove clang from foo/lib/clang + if (!HSOpts.ResourceDir.empty()) { + // Remove version from foo/lib/clang/version + StringRef NoVer = llvm::sys::path::parent_path(HSOpts.ResourceDir); + // Remove clang from foo/lib/clang + SmallString<128> P = llvm::sys::path::parent_path(NoVer); // Get foo/lib/c++/v1 - P.appendComponent("c++"); - P.appendComponent("v1"); + llvm::sys::path::append(P, "c++", "v1"); AddUnmappedPath(P.str(), CXXSystem, false); } } @@ -687,8 +691,8 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS, if (HSOpts.UseBuiltinIncludes) { // Set up the builtin include directory in the module map. - llvm::sys::Path P(HSOpts.ResourceDir); - P.appendComponent("include"); + SmallString<128> P = StringRef(HSOpts.ResourceDir); + llvm::sys::path::append(P, "include"); if (const DirectoryEntry *Dir = HS.getFileMgr().getDirectory(P.str())) HS.getModuleMap().setBuiltinIncludeDir(Dir); } |