[cfe-commits] r81389 - in /cfe/trunk: include/clang/Driver/Driver.h include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Driver/Tools.cpp

Daniel Dunbar daniel at zuster.org
Wed Sep 9 15:33:00 PDT 2009


Author: ddunbar
Date: Wed Sep  9 17:33:00 2009
New Revision: 81389

URL: http://llvm.org/viewvc/llvm-project?rev=81389&view=rev
Log:
Change Get{File,Program}Path to return an std::string (instead of a sys::Path).

Modified:
    cfe/trunk/include/clang/Driver/Driver.h
    cfe/trunk/include/clang/Driver/ToolChain.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/ToolChain.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=81389&r1=81388&r2=81389&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Sep  9 17:33:00 2009
@@ -195,8 +195,9 @@
   ///
   /// \arg TC - The tool chain for additional information on
   /// directories to search.
+  //
   // FIXME: This should be in CompilationInfo.
-  llvm::sys::Path GetFilePath(const char *Name, const ToolChain &TC) const;
+  std::string GetFilePath(const char *Name, const ToolChain &TC) const;
 
   /// GetProgramPath - Lookup \arg Name in the list of program search
   /// paths.
@@ -206,9 +207,10 @@
   ///
   /// \arg WantFile - False when searching for an executable file, otherwise
   /// true.  Defaults to false.
+  //
   // FIXME: This should be in CompilationInfo.
-  llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC,
-                                 bool WantFile = false) const;
+  std::string GetProgramPath(const char *Name, const ToolChain &TC,
+                              bool WantFile = false) const;
 
   /// HandleImmediateArgs - Handle any arguments which should be
   /// treated before building actions or binding tools.

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=81389&r1=81388&r2=81389&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Sep  9 17:33:00 2009
@@ -80,9 +80,9 @@
 
   // Helper methods
 
-  llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const;
-  llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name,
-                                 bool WantFile = false) const;
+  std::string GetFilePath(const Compilation &C, const char *Name) const;
+  std::string GetProgramPath(const Compilation &C, const char *Name,
+                             bool WantFile = false) const;
 
   // Platform defaults information
 

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81389&r1=81388&r2=81389&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Sep  9 17:33:00 2009
@@ -487,19 +487,17 @@
   // FIXME: The following handlers should use a callback mechanism, we don't
   // know what the client would like to do.
   if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) {
-    llvm::outs() << GetFilePath(A->getValue(C.getArgs()), TC).str()
-                 << "\n";
+    llvm::outs() << GetFilePath(A->getValue(C.getArgs()), TC) << "\n";
     return false;
   }
 
   if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) {
-    llvm::outs() << GetProgramPath(A->getValue(C.getArgs()), TC).str()
-                 << "\n";
+    llvm::outs() << GetProgramPath(A->getValue(C.getArgs()), TC) << "\n";
     return false;
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-    llvm::outs() << GetFilePath("libgcc.a", TC).str() << "\n";
+    llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
     return false;
   }
 
@@ -1180,38 +1178,36 @@
   }
 }
 
-llvm::sys::Path Driver::GetFilePath(const char *Name,
-                                    const ToolChain &TC) const {
+std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const {
   const ToolChain::path_list &List = TC.getFilePaths();
   for (ToolChain::path_list::const_iterator
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
     if (P.exists())
-      return P;
+      return P.str();
   }
 
-  return llvm::sys::Path(Name);
+  return Name;
 }
 
-llvm::sys::Path Driver::GetProgramPath(const char *Name,
-                                       const ToolChain &TC,
-                                       bool WantFile) const {
+std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC,
+                                   bool WantFile) const {
   const ToolChain::path_list &List = TC.getProgramPaths();
   for (ToolChain::path_list::const_iterator
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
     if (WantFile ? P.exists() : P.canExecute())
-      return P;
+      return P.str();
   }
 
   // If all else failed, search the path.
   llvm::sys::Path P(llvm::sys::Program::FindProgramByName(Name));
   if (!P.empty())
-    return P;
+    return P.str();
 
-  return llvm::sys::Path(Name);
+  return Name;
 }
 
 std::string Driver::GetTemporaryPath(const char *Suffix) const {

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=81389&r1=81388&r2=81389&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Sep  9 17:33:00 2009
@@ -22,14 +22,14 @@
 ToolChain::~ToolChain() {
 }
 
-llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
-                                       const char *Name) const {
+std::string ToolChain::GetFilePath(const Compilation &C,
+                                   const char *Name) const {
   return Host.getDriver().GetFilePath(Name, *this);
 
 }
 
-llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
-                                          const char *Name,
-                                          bool WantFile) const {
+std::string ToolChain::GetProgramPath(const Compilation &C,
+                                      const char *Name,
+                                      bool WantFile) const {
   return Host.getDriver().GetProgramPath(Name, *this, WantFile);
 }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=81389&r1=81388&r2=81389&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Sep  9 17:33:00 2009
@@ -665,7 +665,7 @@
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "clang-cc").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "clang-cc"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 
   // Explicitly warn that these options are unsupported, even though
@@ -799,7 +799,7 @@
   const char *GCCName =
     getToolChain().getHost().getDriver().CCCGenericGCCName.c_str();
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, GCCName).str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, GCCName));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1162,7 +1162,7 @@
 
   const char *CC1Name = getCC1Name(Inputs[0].getType());
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name).str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1256,7 +1256,7 @@
 
   const char *CC1Name = getCC1Name(Inputs[0].getType());
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name).str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1311,7 +1311,7 @@
   // asm_final spec is empty.
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "as").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "as"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1693,7 +1693,7 @@
         !Args.hasArg(options::OPT_miphoneos_version_min_EQ) &&
         isMacosxVersionLT(MacosxVersion, 10, 5)) {
       const char *Str =
-        Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o").str());
+        Args.MakeArgString(getToolChain().GetFilePath(C, "crt3.o"));
       CmdArgs.push_back(Str);
     }
   }
@@ -1807,7 +1807,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_F);
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 
   // Find the first non-empty base input (we want to ignore linker
@@ -1835,7 +1835,7 @@
     const char *Suffix = strrchr(BaseInput, '.');
     if (Suffix && isSourceSuffix(Suffix + 1)) {
       const char *Exec =
-        Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil").str());
+        Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil"));
       ArgStringList CmdArgs;
       CmdArgs.push_back(Output.getFilename());
       C.getJobs().addCommand(new Command(JA, Exec, CmdArgs));
@@ -1863,7 +1863,7 @@
     CmdArgs.push_back(II.getFilename());
   }
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "lipo").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "lipo"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1893,7 +1893,7 @@
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "as").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "as"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -1937,10 +1937,10 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared)) {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o")));
     } else {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o")));
     }
   }
 
@@ -1985,13 +1985,13 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared))
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o")));
     else
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o")));
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2021,7 +2021,7 @@
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "as").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "as"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2065,10 +2065,10 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared)) {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt0.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o")));
     } else {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o")));
     }
   }
 
@@ -2113,13 +2113,13 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared))
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o")));
     else
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o")));
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2154,7 +2154,7 @@
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "as").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "as"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2198,12 +2198,12 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared)) {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o")));
     } else {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o")));
     }
   }
 
@@ -2258,14 +2258,14 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared))
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o")));
     else
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o").str()));
-    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o")));
+    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o")));
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2304,7 +2304,7 @@
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "as").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "as"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }
 
@@ -2347,12 +2347,12 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared)) {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crt1.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbegin.o")));
     } else {
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o").str()));
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crti.o")));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtbeginS.o")));
     }
   }
 
@@ -2421,13 +2421,13 @@
   if (!Args.hasArg(options::OPT_nostdlib) &&
       !Args.hasArg(options::OPT_nostartfiles)) {
     if (!Args.hasArg(options::OPT_shared))
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtend.o")));
     else
-      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o").str()));
-    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o").str()));
+      CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtendS.o")));
+    CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(C, "crtn.o")));
   }
 
   const char *Exec =
-    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").str());
+    Args.MakeArgString(getToolChain().GetProgramPath(C, "ld"));
   Dest.addCommand(new Command(JA, Exec, CmdArgs));
 }





More information about the cfe-commits mailing list