[llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp

Reid Spencer reid at x10sys.com
Sun Dec 19 10:00:32 PST 2004



Changes in directory llvm/lib/Support:

ToolRunner.cpp updated: 1.36 -> 1.37
---
Log message:

For PR351: http://llvm.cs.uiuc.edu/PR351 :
* Pass sys::Path instead of std::string for paths
* Correct the types of arguments passed to RunProgramWithTimeout due to its
  interface using sys::Path instead of std::string
* Replace "/dev/null" (not portable) with empty string which 
  sys::Program::ExecuteAndWait recognizes as "redirect to bit bucket" 

---
Diffs of the changes:  (+27 -24)

Index: llvm/lib/Support/ToolRunner.cpp
diff -u llvm/lib/Support/ToolRunner.cpp:1.36 llvm/lib/Support/ToolRunner.cpp:1.37
--- llvm/lib/Support/ToolRunner.cpp:1.36	Thu Dec 16 17:01:34 2004
+++ llvm/lib/Support/ToolRunner.cpp	Sun Dec 19 12:00:21 2004
@@ -22,7 +22,7 @@
 
 ToolExecutionError::~ToolExecutionError() throw() { }
 
-static void ProcessFailure(std::string ProgPath, const char** Args) {
+static void ProcessFailure(sys::Path ProgPath, const char** Args) {
   std::ostringstream OS;
   OS << "\nError running tool:\n ";
   for (const char **Arg = Args; *Arg; ++Arg)
@@ -32,8 +32,8 @@
   // Rerun the compiler, capturing any error messages to print them.
   sys::Path ErrorFilename("error_messages");
   ErrorFilename.makeUnique();
-  RunProgramWithTimeout(ProgPath, Args, "/dev/null", ErrorFilename.c_str(),
-                        ErrorFilename.c_str());
+  RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
+                        ErrorFilename);
 
   // Print out the error messages generated by GCC if possible...
   std::ifstream ErrorFile(ErrorFilename.c_str());
@@ -102,8 +102,9 @@
           std::cerr << " " << LLIArgs[i];
         std::cerr << "\n";
         );
-  return RunProgramWithTimeout(LLIPath, &LLIArgs[0],
-                               InputFile, OutputFile, OutputFile, Timeout);
+  return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0],
+      sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), 
+      Timeout);
 }
 
 // LLI create method - Try to find the LLI executable
@@ -146,9 +147,9 @@
           std::cerr << " " << LLCArgs[i];
         std::cerr << "\n";
         );
-  if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
-                            "/dev/null"))
-    ProcessFailure(LLCPath, &LLCArgs[0]);
+  if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], 
+                            sys::Path(), sys::Path(), sys::Path()))
+    ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]);
 }
 
 void LLC::compileProgram(const std::string &Bytecode) {
@@ -248,8 +249,9 @@
         std::cerr << "\n";
         );
   DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
-  return RunProgramWithTimeout(LLIPath, &JITArgs[0],
-                               InputFile, OutputFile, OutputFile, Timeout);
+  return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0],
+      sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), 
+      Timeout);
 }
 
 /// createJIT - Try to find the LLI executable
@@ -290,8 +292,8 @@
           std::cerr << " " << LLCArgs[i];
         std::cerr << "\n";
         );
-  if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], "/dev/null", "/dev/null",
-                            "/dev/null"))
+  if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), 
+                            sys::Path()))
     ProcessFailure(LLCPath, &LLCArgs[0]);
 }
 
@@ -321,14 +323,14 @@
 CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
                                     std::string &Message,
                                     const std::vector<std::string> *Args) {
-  std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
-  if (LLCPath.empty()) {
+  sys::Path LLCPath = FindExecutable("llc", ProgramPath);
+  if (LLCPath.isEmpty()) {
     Message = 
       "Cannot find `llc' in executable directory or PATH!\n";
     return 0;
   }
 
-  Message = "Found llc: " + LLCPath + "\n";
+  Message = "Found llc: " + LLCPath.toString() + "\n";
   GCC *gcc = GCC::create(ProgramPath, Message);
   if (!gcc) {
     std::cerr << Message << "\n";
@@ -376,8 +378,8 @@
   GCCArgs.push_back(0);                    // NULL terminator
 
   std::cout << "<gcc>" << std::flush;
-  if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], "/dev/null", "/dev/null",
-                            "/dev/null")) {
+  if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
+        sys::Path())) {
     ProcessFailure(GCCPath, &GCCArgs[0]);
     exit(1);
   }
@@ -398,8 +400,9 @@
         );
 
   FileRemover OutputBinaryRemover(OutputBinary);
-  return RunProgramWithTimeout(OutputBinary.toString(), &ProgramArgs[0],
-                               InputFile, OutputFile, OutputFile, Timeout);
+  return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
+      sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), 
+      Timeout);
 }
 
 int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
@@ -431,8 +434,8 @@
   };
   
   std::cout << "<gcc>" << std::flush;
-  if (RunProgramWithTimeout(GCCPath, GCCArgs, "/dev/null", "/dev/null",
-                            "/dev/null")) {
+  if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(), 
+                            sys::Path())) {
     ProcessFailure(GCCPath, GCCArgs);
     return 1;
   }
@@ -442,12 +445,12 @@
 /// create - Try to find the `gcc' executable
 ///
 GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
-  std::string GCCPath = FindExecutable("gcc", ProgramPath).toString();
-  if (GCCPath.empty()) {
+  sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
+  if (GCCPath.isEmpty()) {
     Message = "Cannot find `gcc' in executable directory or PATH!\n";
     return 0;
   }
 
-  Message = "Found gcc: " + GCCPath + "\n";
+  Message = "Found gcc: " + GCCPath.toString() + "\n";
   return new GCC(GCCPath);
 }






More information about the llvm-commits mailing list