Support/PathV1: Deprecate get{Basename,Dirname,Suffix}.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Sat, 18 Dec 2010 22:23:07 +0000 (22:23 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Sat, 18 Dec 2010 22:23:07 +0000 (22:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122157 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PathV1.h
lib/CompilerDriver/CompilationGraph.cpp
lib/CompilerDriver/Main.cpp
lib/CompilerDriver/Tool.cpp
lib/Linker/LinkModules.cpp
tools/llvm-ld/llvm-ld.cpp
utils/KillTheDoctor/KillTheDoctor.cpp

index 818b32964eea173b1229fa29071850990540de08..cac6226ac8fcb45cf50eb778f3000fe098912f66 100644 (file)
@@ -272,11 +272,13 @@ namespace sys {
       /// this function to return "foo".
       /// @returns StringRef containing the basename of the path
       /// @brief Get the base name of the path
-      StringRef getBasename() const;
+      LLVM_ATTRIBUTE_DEPRECATED(StringRef getBasename() const,
+        LLVMV_PATH_DEPRECATED_MSG);
 
       /// This function strips off the suffix of the path beginning with the
       /// path separator ('/' on Unix, '\' on Windows) and returns the result.
-      StringRef getDirname() const;
+      LLVM_ATTRIBUTE_DEPRECATED(StringRef getDirname() const,
+        LLVMV_PATH_DEPRECATED_MSG);
 
       /// This function strips off the path and basename(up to and
       /// including the last dot) of the file or directory name and
@@ -284,7 +286,8 @@ namespace sys {
       /// this function to return "bar".
       /// @returns StringRef containing the suffix of the path
       /// @brief Get the suffix of the path
-      StringRef getSuffix() const;
+      LLVM_ATTRIBUTE_DEPRECATED(StringRef getSuffix() const,
+        LLVMV_PATH_DEPRECATED_MSG);
 
       /// Obtain a 'C' string for the path name.
       /// @returns a 'C' string containing the path name.
index 87a2c4817a842487c8d260d2ac18ba7976c4a632..33c6566499b8777bd7084293115be9df8525a0f5 100644 (file)
@@ -32,7 +32,8 @@ using namespace llvmc;
 namespace llvmc {
 
   const std::string* LanguageMap::GetLanguage(const sys::Path& File) const {
-    StringRef suf = File.getSuffix();
+    // Remove the '.'.
+    StringRef suf = sys::path::extension(File.str()).substr(1);
     LanguageMap::const_iterator Lang =
       this->find(suf.empty() ? "*empty*" : suf);
     if (Lang == this->end()) {
index 4f8794041b9afac67960773b1a76fceb77244a99..88cfdb21230513e4e7c4b5b5f4369fd736a817ef 100644 (file)
@@ -43,8 +43,7 @@ namespace {
       return 0;
     }
     else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) {
-      tempDir = OutputFilename;
-      tempDir = tempDir.getDirname();
+      tempDir = sys::path::parent_path(OutputFilename);
     }
     else {
       // SaveTemps == Cwd --> use current dir (leave tempDir empty).
index 232bd41c4ba2a288207f81cfd6b8de3bb2b7bfc9..876759aa72b00420a368a3e5a7d8f21923bb9fcb 100644 (file)
@@ -61,7 +61,7 @@ sys::Path Tool::OutFilename(const sys::Path& In,
       Out.appendSuffix(OutputSuffix);
     }
     else {
-      Out.set(In.getBasename());
+      Out.set(sys::path::stem(In.str()));
       Out.appendSuffix(OutputSuffix);
     }
   }
@@ -69,7 +69,7 @@ sys::Path Tool::OutFilename(const sys::Path& In,
     if (IsJoin())
       Out = MakeTempFile(TempDir, "tmp", OutputSuffix);
     else
-      Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix);
+      Out = MakeTempFile(TempDir, sys::path::stem(In.str()), OutputSuffix);
   }
   return Out;
 }
index dd0b07e09bda59f24a4ad2ef0327dfa2d82260e7..c710d7ee8692a2c93c2fdfe3ff02621bcb252a54 100644 (file)
@@ -1301,10 +1301,9 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
 
   // If the source library's module id is in the dependent library list of the
   // destination library, remove it since that module is now linked in.
-  sys::Path modId;
-  modId.set(Src->getModuleIdentifier());
-  if (!modId.isEmpty())
-    Dest->removeLibrary(modId.getBasename());
+  const std::string &modId = Src->getModuleIdentifier();
+  if (!modId.empty())
+    Dest->removeLibrary(sys::path::stem(modId));
 
   return false;
 }
index 445366c0f73a689b89c004fd67be82a8eba28556..475fcf4d8ac8c9838177f3c4fec8f480b532ffe2 100644 (file)
@@ -526,7 +526,7 @@ int main(int argc, char **argv, char **envp) {
   initializeTarget(Registry);
 
   // Initial global variable above for convenience printing of program name.
-  progname = sys::Path(argv[0]).getBasename();
+  progname = sys::path::stem(argv[0]);
 
   // Parse the command line options
   cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
@@ -538,11 +538,8 @@ int main(int argc, char **argv, char **envp) {
       OutputFilename = "a.exe";
 
     // If there is no suffix add an "exe" one.
-    sys::Path ExeFile( OutputFilename );
-    if (ExeFile.getSuffix() == "") {
-      ExeFile.appendSuffix("exe");
-      OutputFilename = ExeFile.str();
-    }
+    if (sys::path::extension(OutputFilename).empty())
+      OutputFilename.append(".exe");
   }
 #endif
 
index a623d6af8d9ca6094e72681ea9dda4036031a45a..7a89dd379b70f5cd9c7e42a51845013d9f04ec79 100644 (file)
@@ -523,7 +523,7 @@ int main(int argc, char **argv) {
           errs().indent(ToolName.size()) << ": DLL Name : " << DLLName << '\n';
         }
 
-        if (NoUser32 && sys::Path(DLLName).getBasename() == "user32") {
+        if (NoUser32 && sys::path::stem(DLLName) == "user32") {
           // Program is loading user32.dll, in the applications we are testing,
           // this only happens if an assert has fired. By now the message has
           // already been printed, so simply close the program.