]> granicus.if.org Git - clang/commitdiff
Modernize some low-hanging PathV1 uses.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 13 Jun 2013 14:26:04 +0000 (14:26 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 13 Jun 2013 14:26:04 +0000 (14:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183903 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/FileRemapper.cpp
lib/Frontend/DependencyFile.cpp
lib/Frontend/InitHeaderSearch.cpp

index 14fa179d4bdd940720ed3360c0e05ea3de2462d5..ee33c8f3e8ecb42e439f972664ff44d49c558473 100644 (file)
@@ -14,7 +14,6 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PathV1.h"
 #include "llvm/Support/raw_ostream.h"
 #include <fstream>
 
@@ -44,10 +43,9 @@ void FileRemapper::clear(StringRef outputDir) {
 
 std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
   assert(!outputDir.empty());
-  llvm::sys::Path dir(outputDir);
-  llvm::sys::Path infoFile = dir;
-  infoFile.appendComponent("remap");
-  return infoFile.str();
+  SmallString<128> InfoFile = outputDir;
+  llvm::sys::path::append(InfoFile, "remap");
+  return InfoFile.str();
 }
 
 bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
index 0c6ab4a0bd8db6a812030049070a4e311ab15cec..4037af9055d57a6e462d0e388bc3283f11defbb3 100644 (file)
@@ -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;
   }
 
index 46694d985df03bde20d6c81f083ea7c7a15fca20..3691adf3b9f2eed4b143eec8d07e07ecb32306ce 100644 (file)
@@ -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);
   }