[llvm-commits] CVS: llvm/tools/llvmc/CompilerDriver.cpp

Reid Spencer reid at x10sys.com
Tue Aug 22 12:01:49 PDT 2006



Changes in directory llvm/tools/llvmc:

CompilerDriver.cpp updated: 1.39 -> 1.40
---
Log message:

Make the sys::Path::GetTemporaryDirectory method not throw exceptions and
adjust users of it to compensate.


---
Diffs of the changes:  (+30 -10)

 CompilerDriver.cpp |   40 ++++++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 10 deletions(-)


Index: llvm/tools/llvmc/CompilerDriver.cpp
diff -u llvm/tools/llvmc/CompilerDriver.cpp:1.39 llvm/tools/llvmc/CompilerDriver.cpp:1.40
--- llvm/tools/llvmc/CompilerDriver.cpp:1.39	Mon Aug 21 01:04:45 2006
+++ llvm/tools/llvmc/CompilerDriver.cpp	Tue Aug 22 14:01:30 2006
@@ -83,8 +83,6 @@
     , TempDir()
     , AdditionalArgs()
   {
-    TempDir = sys::Path::GetTemporaryDirectory();
-    sys::RemoveDirectoryOnSignal(TempDir);
     AdditionalArgs.reserve(NUM_PHASES);
     StringVector emptyVec;
     for (unsigned i = 0; i < NUM_PHASES; ++i)
@@ -196,12 +194,25 @@
   }
 
   sys::Path MakeTempFile(const std::string& basename,
-                         const std::string& suffix) {
+                         const std::string& suffix,
+                         std::string* ErrMsg) {
+    if (TempDir.isEmpty()) {
+      TempDir = sys::Path::GetTemporaryDirectory(ErrMsg);
+      if (TempDir.isEmpty())
+        return sys::Path();
+      sys::RemoveDirectoryOnSignal(TempDir);
+    }
     sys::Path result(TempDir);
-    if (!result.appendComponent(basename))
-      throw basename + ": can't use this file name";
-    if (!result.appendSuffix(suffix))
-      throw suffix + ": can't use this file suffix";
+    if (!result.appendComponent(basename)) {
+      if (ErrMsg)
+        *ErrMsg = basename + ": can't use this file name";
+      return sys::Path();
+    }
+    if (!result.appendSuffix(suffix)) {
+      if (ErrMsg)
+        *ErrMsg = suffix + ": can't use this file suffix";
+      return sys::Path();
+    }
     return result;
   }
 
@@ -700,7 +711,10 @@
                 actions.push_back(GetAction(cd,InFile,Output,PREPROCESSING));
               }
             } else {
-              sys::Path TempFile(MakeTempFile(I->first.getBasename(),"E"));
+              sys::Path TempFile(
+                  MakeTempFile(I->first.getBasename(),"E",&ErrMsg));
+              if (TempFile.isEmpty())
+                return 1;
               actions.push_back(GetAction(cd,InFile,TempFile,
                 PREPROCESSING));
               InFile = TempFile;
@@ -731,7 +745,10 @@
                 actions.push_back(GetAction(cd,InFile,Output,TRANSLATION));
               }
             } else {
-              sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans"));
+              sys::Path TempFile(
+                  MakeTempFile(I->first.getBasename(),"trans", &ErrMsg));
+              if (TempFile.isEmpty())
+                return 1;
               actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION));
               InFile = TempFile;
             }
@@ -774,7 +791,10 @@
                   actions.push_back(GetAction(cd,InFile,Output,OPTIMIZATION));
                 }
               } else {
-                sys::Path TempFile(MakeTempFile(I->first.getBasename(),"opt"));
+                sys::Path TempFile(
+                  MakeTempFile(I->first.getBasename(),"opt", &ErrMsg));
+                if (TempFile.isEmpty())
+                  return 1;
                 actions.push_back(GetAction(cd,InFile,TempFile,OPTIMIZATION));
                 InFile = TempFile;
               }






More information about the llvm-commits mailing list