Add a --save-temps option.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51760 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvmc2/CompilationGraph.cpp b/tools/llvmc2/CompilationGraph.cpp
index df1f239..9cdcac3 100644
--- a/tools/llvmc2/CompilationGraph.cpp
+++ b/tools/llvmc2/CompilationGraph.cpp
@@ -139,8 +139,17 @@
 namespace {
   sys::Path MakeTempFile(const sys::Path& TempDir, const std::string& BaseName,
                          const std::string& Suffix) {
-    sys::Path Out = TempDir;
-    Out.appendComponent(BaseName);
+    sys::Path Out;
+
+    // Make sure we don't end up with path names like '/file.o' if the
+    // TempDir is empty.
+    if (TempDir.empty()) {
+      Out.set(BaseName);
+    }
+    else {
+      Out = TempDir;
+      Out.appendComponent(BaseName);
+    }
     Out.appendSuffix(Suffix);
     Out.makeUnique(true, NULL);
     return Out;