Add save-temps option to bugpoint to keep temporary stuff.
Patch by Sandeep Patel

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78183 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index ef07079..81314a8 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -22,6 +22,11 @@
 #include <sstream>
 using namespace llvm;
 
+namespace llvm {
+  cl::opt<bool>
+  SaveTemps("save-temps", cl::init(false), cl::desc("Save temporary files"));
+}
+
 namespace {
   cl::opt<std::string>
   RemoteClient("remote-client",
@@ -395,7 +400,7 @@
 
   sys::Path OutputAsmFile;
   OutputCode(Bitcode, OutputAsmFile);
-  FileRemover OutFileRemover(OutputAsmFile);
+  FileRemover OutFileRemover(OutputAsmFile, !SaveTemps);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
   GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
@@ -560,7 +565,7 @@
   sys::Path OutputCFile;
   OutputCode(Bitcode, OutputCFile);
 
-  FileRemover CFileRemove(OutputCFile);
+  FileRemover CFileRemove(OutputCFile, !SaveTemps);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
   GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
@@ -726,7 +731,7 @@
         errs() << "\n";
         );
 
-  FileRemover OutputBinaryRemover(OutputBinary);
+  FileRemover OutputBinaryRemover(OutputBinary, !SaveTemps);
 
   if (RemoteClientPath.isEmpty()) {
     DEBUG(errs() << "<run locally>";);