[llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp CrashDebugger.cpp ExecutionDriver.cpp Miscompilation.cpp OptimizerDriver.cpp

Reid Spencer reid at x10sys.com
Thu Dec 16 15:04:31 PST 2004



Changes in directory llvm/tools/bugpoint:

BugDriver.cpp updated: 1.39 -> 1.40
CrashDebugger.cpp updated: 1.38 -> 1.39
ExecutionDriver.cpp updated: 1.49 -> 1.50
Miscompilation.cpp updated: 1.57 -> 1.58
OptimizerDriver.cpp updated: 1.25 -> 1.26
---
Log message:

For PR351: http://llvm.cs.uiuc.edu/PR351 :
* removeFile() -> sys::Path::destroyFile()
* remove extraneous toString() calls
* convert local variables representing path names from std::string to
  sys::Path
* Use sys::Path objects with FileRemove instead of std::string
* Use sys::Path methods for construction of path names 


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

Index: llvm/tools/bugpoint/BugDriver.cpp
diff -u llvm/tools/bugpoint/BugDriver.cpp:1.39 llvm/tools/bugpoint/BugDriver.cpp:1.40
--- llvm/tools/bugpoint/BugDriver.cpp:1.39	Sun Dec 12 21:01:03 2004
+++ llvm/tools/bugpoint/BugDriver.cpp	Thu Dec 16 17:04:20 2004
@@ -175,7 +175,7 @@
 
   // Make sure the reference output file gets deleted on exit from this
   // function, if appropriate.
-  FileRemover RemoverInstance(ReferenceOutputFile, CreatedOutput);
+  FileRemover RemoverInstance(sys::Path(ReferenceOutputFile), CreatedOutput);
 
   // Diff the output of the raw program against the reference output.  If it
   // matches, then we have a miscompilation bug.


Index: llvm/tools/bugpoint/CrashDebugger.cpp
diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.38 llvm/tools/bugpoint/CrashDebugger.cpp:1.39
--- llvm/tools/bugpoint/CrashDebugger.cpp:1.38	Wed Sep  1 17:55:37 2004
+++ llvm/tools/bugpoint/CrashDebugger.cpp	Thu Dec 16 17:04:20 2004
@@ -49,23 +49,25 @@
 ReducePassList::TestResult
 ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
                        std::vector<const PassInfo*> &Suffix) {
-  std::string PrefixOutput;
+  sys::Path PrefixOutput;
   Module *OrigProgram = 0;
   if (!Prefix.empty()) {
     std::cout << "Checking to see if these passes crash: "
               << getPassesString(Prefix) << ": ";
-    if (BD.runPasses(Prefix, PrefixOutput))
+    std::string PfxOutput;
+    if (BD.runPasses(Prefix, PfxOutput))
       return KeepPrefix;
 
+    PrefixOutput.setFile(PfxOutput);
     OrigProgram = BD.Program;
 
-    BD.Program = ParseInputFile(PrefixOutput);
+    BD.Program = ParseInputFile(PrefixOutput.toString());
     if (BD.Program == 0) {
       std::cerr << BD.getToolName() << ": Error reading bytecode file '"
                 << PrefixOutput << "'!\n";
       exit(1);
     }
-    removeFile(PrefixOutput);
+    PrefixOutput.destroyFile();
   }
 
   std::cout << "Checking to see if these passes crash: "


Index: llvm/tools/bugpoint/ExecutionDriver.cpp
diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.49 llvm/tools/bugpoint/ExecutionDriver.cpp:1.50
--- llvm/tools/bugpoint/ExecutionDriver.cpp:1.49	Tue Dec 14 19:53:08 2004
+++ llvm/tools/bugpoint/ExecutionDriver.cpp	Thu Dec 16 17:04:20 2004
@@ -161,7 +161,7 @@
   }
 
     // Remove the temporary bytecode file when we are done.
-  FileRemover BytecodeFileRemover(BytecodeFile.toString());
+  FileRemover BytecodeFileRemover(BytecodeFile);
 
   // Actually compile the program!
   Interpreter->compileProgram(BytecodeFile.toString());
@@ -195,7 +195,7 @@
   }
 
   // Remove the temporary bytecode file when we are done.
-  FileRemover BytecodeFileRemover(BytecodeFile, CreatedBytecode);
+  FileRemover BytecodeFileRemover(sys::Path(BytecodeFile), CreatedBytecode);
 
   if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
 
@@ -252,7 +252,7 @@
 
 std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
   assert(Interpreter && "Interpreter should have been created already!");
-  std::string OutputCFile;
+  sys::Path OutputCFile;
 
   // Using CBE
   cbe->OutputC(BytecodeFile, OutputCFile);
@@ -268,11 +268,12 @@
 #endif
 
   std::string SharedObjectFile;
-  if (gcc->MakeSharedObject(OutputCFile, GCC::CFile, SharedObjectFile))
+  if (gcc->MakeSharedObject(OutputCFile.toString(), GCC::CFile, 
+                            SharedObjectFile))
     exit(1);
 
   // Remove the intermediate C file
-  removeFile(OutputCFile);
+  OutputCFile.destroyFile();
 
   return "./" + SharedObjectFile;
 }
@@ -288,19 +289,20 @@
   bool ProgramExitedNonzero;
 
   // Execute the program, generating an output file...
-  std::string Output = executeProgram("", BytecodeFile, SharedObject, 0,
-                                      &ProgramExitedNonzero);
+  sys::Path Output (executeProgram("", BytecodeFile, SharedObject, 0,
+                                      &ProgramExitedNonzero));
 
   // If we're checking the program exit code, assume anything nonzero is bad.
   if (CheckProgramExitCode && ProgramExitedNonzero) {
-    removeFile(Output);
-    if (RemoveBytecode) removeFile(BytecodeFile);
+    Output.destroyFile();
+    if (RemoveBytecode) 
+      sys::Path(BytecodeFile).destroyFile();
     return true;
   }
 
   std::string Error;
   bool FilesDifferent = false;
-  if (DiffFiles(ReferenceOutputFile, Output, &Error)) {
+  if (DiffFiles(ReferenceOutputFile, Output.toString(), &Error)) {
     if (!Error.empty()) {
       std::cerr << "While diffing output: " << Error << '\n';
       exit(1);
@@ -309,10 +311,10 @@
   }
   
   // Remove the generated output.
-  removeFile(Output);
+  Output.destroyFile();
 
   // Remove the bytecode file if we are supposed to.
-  if (RemoveBytecode) removeFile(BytecodeFile);
+  if (RemoveBytecode) sys::Path(BytecodeFile).destroyFile();
   return FilesDifferent;
 }
 


Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.57 llvm/tools/bugpoint/Miscompilation.cpp:1.58
--- llvm/tools/bugpoint/Miscompilation.cpp:1.57	Tue Dec 14 19:53:08 2004
+++ llvm/tools/bugpoint/Miscompilation.cpp	Thu Dec 16 17:04:20 2004
@@ -93,7 +93,7 @@
   // If the prefix maintains the predicate by itself, only keep the prefix!
   if (BD.diffProgram(BytecodeResult)) {
     std::cout << " nope.\n";
-    removeFile(BytecodeResult);
+    sys::Path(BytecodeResult).destroyFile();
     return KeepPrefix;
   }
   std::cout << " yup.\n";      // No miscompilation!
@@ -107,7 +107,7 @@
               << BytecodeResult << "'!\n";
     exit(1);
   }
-  removeFile(BytecodeResult);  // No longer need the file on disk
+  sys::Path(BytecodeResult).destroyFile();  // No longer need the file on disk
 
   // Don't check if there are no passes in the suffix.
   if (Suffix.empty())
@@ -760,9 +760,9 @@
     std::cerr << ": still failing!\n";
   else
     std::cerr << ": didn't fail.\n";
-  removeFile(TestModuleBC.toString());
-  removeFile(SafeModuleBC.toString());
-  removeFile(SharedObject);
+  TestModuleBC.destroyFile();
+  SafeModuleBC.destroyFile();
+  sys::Path(SharedObject).destroyFile();
 
   return Result;
 }


Index: llvm/tools/bugpoint/OptimizerDriver.cpp
diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.25 llvm/tools/bugpoint/OptimizerDriver.cpp:1.26
--- llvm/tools/bugpoint/OptimizerDriver.cpp:1.25	Tue Dec 14 19:53:08 2004
+++ llvm/tools/bugpoint/OptimizerDriver.cpp	Thu Dec 16 17:04:20 2004
@@ -143,7 +143,7 @@
   // If we are supposed to delete the bytecode file or if the passes crashed,
   // remove it now.  This may fail if the file was never created, but that's ok.
   if (DeleteOutput || !ExitedOK)
-    removeFile(OutputFilename);
+    sys::Path(OutputFilename).destroyFile();
   
   if (!Quiet) {
     if (ExitedOK)
@@ -194,6 +194,6 @@
               << BytecodeResult << "'!\n";
     exit(1);
   }
-  removeFile(BytecodeResult);  // No longer need the file on disk
+  sys::Path(BytecodeResult).destroyFile();  // No longer need the file on disk
   return Ret;
 }






More information about the llvm-commits mailing list