[cfe-commits] r122140 - in /cfe/trunk: lib/Checker/AnalysisConsumer.cpp lib/Driver/Driver.cpp lib/Rewrite/FrontendActions.cpp tools/driver/driver.cpp

Michael J. Spencer bigcheesegs at gmail.com
Fri Dec 17 20:13:32 PST 2010


Author: mspencer
Date: Fri Dec 17 22:13:32 2010
New Revision: 122140

URL: http://llvm.org/viewvc/llvm-project?rev=122140&view=rev
Log:
Replace all uses of PathV1::get{Basename,Dirname,Suffix} with their PathV2 equivalents.

Modified:
    cfe/trunk/lib/Checker/AnalysisConsumer.cpp
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Rewrite/FrontendActions.cpp
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/lib/Checker/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AnalysisConsumer.cpp?rev=122140&r1=122139&r2=122140&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Checker/AnalysisConsumer.cpp Fri Dec 17 22:13:32 2010
@@ -50,8 +50,8 @@
 static PathDiagnosticClient*
 createPlistHTMLDiagnosticClient(const std::string& prefix,
                                 const Preprocessor &PP) {
-  llvm::sys::Path F(prefix);
-  PathDiagnosticClient *PD = createHTMLDiagnosticClient(F.getDirname(), PP);
+  PathDiagnosticClient *PD =
+    createHTMLDiagnosticClient(llvm::sys::path::parent_path(prefix), PP);
   return createPlistDiagnosticClient(prefix, PP, PD);
 }
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=122140&r1=122139&r2=122140&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Dec 17 22:13:32 2010
@@ -77,21 +77,16 @@
       CCCUseClangCXX = false;
   }
 
-  llvm::sys::Path Executable(ClangExecutable);
-  Name = Executable.getBasename();
-  Dir = Executable.getDirname();
+  Name = llvm::sys::path::stem(ClangExecutable);
+  Dir  = llvm::sys::path::parent_path(ClangExecutable);
 
   // Compute the path to the resource directory.
   llvm::StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
-  llvm::sys::Path P(Dir);
-  if (ClangResourceDir != "") {
-    P.appendComponent(ClangResourceDir);
-  } else {
-    P.appendComponent(".."); // Walk up from a 'bin' subdirectory.
-    P.appendComponent("lib");
-    P.appendComponent("clang");
-    P.appendComponent(CLANG_VERSION_STRING);
-  }
+  llvm::SmallString<128> P(Dir);
+  if (ClangResourceDir != "")
+    llvm::sys::path::append(P, ClangResourceDir);
+  else
+    llvm::sys::path::append(P, "..", "lib", "clang", CLANG_VERSION_STRING);
   ResourceDir = P.str();
 }
 

Modified: cfe/trunk/lib/Rewrite/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/FrontendActions.cpp?rev=122140&r1=122139&r2=122140&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Rewrite/FrontendActions.cpp Fri Dec 17 22:13:32 2010
@@ -58,11 +58,10 @@
   }
 
   std::string RewriteFilename(const std::string &Filename) {
-    llvm::sys::Path Path(Filename);
-    std::string Suffix = Path.getSuffix();
-    Path.eraseSuffix();
-    Path.appendSuffix(NewSuffix + "." + Suffix);
-    return Path.c_str();
+    llvm::SmallString<128> Path(Filename);
+    llvm::sys::path::replace_extension(Path,
+      NewSuffix + llvm::sys::path::extension(Path));
+    return Path.str();
   }
 };
 } // end anonymous namespace

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=122140&r1=122139&r2=122140&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Dec 17 22:13:32 2010
@@ -287,7 +287,7 @@
 
   TextDiagnosticPrinter *DiagClient
     = new TextDiagnosticPrinter(llvm::errs(), DiagnosticOptions());
-  DiagClient->setPrefix(Path.getBasename());
+  DiagClient->setPrefix(llvm::sys::path::stem(Path.str()));
   llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
   Diagnostic Diags(DiagID, DiagClient);
 
@@ -331,7 +331,7 @@
   //
   // We use *argv instead of argv[0] to work around a bogus g++ warning.
   const char *progname = argv_[0];
-  std::string ProgName(llvm::sys::Path(progname).getBasename());
+  std::string ProgName(llvm::sys::path::stem(progname));
   if (llvm::StringRef(ProgName).endswith("++") ||
       llvm::StringRef(ProgName).rsplit('-').first.endswith("++")) {
     TheDriver.CCCIsCXX = true;





More information about the cfe-commits mailing list