Simplify some getNode calls.
[oota-llvm.git] / tools / llvmc2 / llvmc.cpp
index ba2d70a62031d3e79f33c9ba0e63bc9a566c39ce..e073845d09e07978666672e3880cca0241012946 100644 (file)
@@ -32,9 +32,6 @@ using namespace llvmc;
 // Built-in command-line options.
 // External linkage here is intentional.
 
-// TOFIX: Add a --keep-temps option.
-// TOFIX: Write a 'driver driver' (easier to do as a separate
-// executable that drives llvmc2 proper).
 cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),
                                      cl::ZeroOrMore);
 cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
@@ -42,6 +39,8 @@ cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
 cl::list<std::string> Languages("x",
           cl::desc("Specify the language of the following input files"),
           cl::ZeroOrMore);
+cl::opt<bool> DryRun("dry-run",
+                     cl::desc("Only pretend to run commands"));
 cl::opt<bool> VerboseMode("v",
                           cl::desc("Enable verbose mode"));
 cl::opt<bool> WriteGraph("write-graph",
@@ -50,12 +49,17 @@ cl::opt<bool> WriteGraph("write-graph",
 cl::opt<bool> ViewGraph("view-graph",
                          cl::desc("Show compilation graph in GhostView"),
                          cl::Hidden);
+cl::opt<bool> SaveTemps("save-temps",
+                         cl::desc("Keep temporary files"),
+                         cl::Hidden);
 
 namespace {
   /// BuildTargets - A small wrapper for CompilationGraph::Build.
   int BuildTargets(CompilationGraph& graph) {
     int ret;
-    sys::Path tempDir(sys::Path::GetTemporaryDirectory());
+    const sys::Path& tempDir = SaveTemps
+      ? sys::Path("")
+      : sys::Path(sys::Path::GetTemporaryDirectory());
 
     try {
       ret = graph.Build(tempDir);
@@ -65,7 +69,8 @@ namespace {
       throw;
     }
 
-    tempDir.eraseFromDisk(true);
+    if (!SaveTemps)
+      tempDir.eraseFromDisk(true);
     return ret;
   }
 }