diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 19:01:30 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 19:01:30 +0000 |
commit | 487447626c273962744820a370d93ddef961c3f2 (patch) | |
tree | 5452a7c4f1d9d37faf155d7e486719795ae96023 /tools/llvmc/CompilerDriver.cpp | |
parent | be4f88a8b8bb3311e0dc4cde8533763d7923c3ea (diff) |
Make the sys::Path::GetTemporaryDirectory method not throw exceptions and
adjust users of it to compensate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc/CompilerDriver.cpp')
-rw-r--r-- | tools/llvmc/CompilerDriver.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index a204964cd8..a6aff4eb30 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -83,8 +83,6 @@ public: , 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 @@ private: } 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 @@ public: 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 @@ public: 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 @@ public: 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; } |