summaryrefslogtreecommitdiffstats
path: root/lib/CompilerDriver
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-07-09 19:37:17 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-07-09 19:37:17 +0000
commitf5f9a4d7db5bc4bb70e551d3ba2d0419425a5cc1 (patch)
treeb29395a877d41fe38c45f2c35534b395cd6c5567 /lib/CompilerDriver
parent3a780d1214f54e943b45a657702bd76166587167 (diff)
downloadexternal_llvm-f5f9a4d7db5bc4bb70e551d3ba2d0419425a5cc1.zip
external_llvm-f5f9a4d7db5bc4bb70e551d3ba2d0419425a5cc1.tar.gz
external_llvm-f5f9a4d7db5bc4bb70e551d3ba2d0419425a5cc1.tar.bz2
Remove some duplication.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CompilerDriver')
-rw-r--r--lib/CompilerDriver/Main.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp
index 86863dc..cd7bc47 100644
--- a/lib/CompilerDriver/Main.cpp
+++ b/lib/CompilerDriver/Main.cpp
@@ -31,31 +31,29 @@ namespace {
sys::Path getTempDir() {
sys::Path tempDir;
- if (! TempDirname.empty()) {
+ // The --temp-dir option.
+ if (!TempDirname.empty()) {
tempDir = TempDirname;
- if (!tempDir.exists()) {
- std::string ErrMsg;
- if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
- throw std::runtime_error(ErrMsg);
- }
- return tempDir;
}
-
// GCC 4.5-style -save-temps handling.
- if (SaveTemps == SaveTempsEnum::Unset) {
+ else if (SaveTemps == SaveTempsEnum::Unset) {
tempDir = sys::Path::GetTemporaryDirectory();
+ return tempDir;
}
else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) {
tempDir = OutputFilename;
tempDir = tempDir.getDirname();
+ }
+ else {
+ // SaveTemps == Cwd --> use current dir (leave tempDir empty).
+ return tempDir;
+ }
- if (!tempDir.exists()) {
- std::string ErrMsg;
- if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
- throw std::runtime_error(ErrMsg);
- }
+ if (!tempDir.exists()) {
+ std::string ErrMsg;
+ if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
+ throw std::runtime_error(ErrMsg);
}
- // else if (SaveTemps == Cwd) -> use current dir (leave tempDir empty)
return tempDir;
}
@@ -64,17 +62,19 @@ namespace {
int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) {
int ret;
const sys::Path& tempDir = getTempDir();
+ bool toDelete =
+ (SaveTemps == SaveTempsEnum::Unset && TempDirname.empty());
try {
ret = graph.Build(tempDir, langMap);
}
catch(...) {
- if (SaveTemps == SaveTempsEnum::Unset)
+ if (toDelete)
tempDir.eraseFromDisk(true);
throw;
}
- if (SaveTemps == SaveTempsEnum::Unset)
+ if (toDelete)
tempDir.eraseFromDisk(true);
return ret;
}