[llvm-commits] [llvm] r75163 - /llvm/trunk/lib/CompilerDriver/Main.cpp
Mikhail Glushenkov
foldr at codedgers.com
Thu Jul 9 12:37:18 PDT 2009
Author: foldr
Date: Thu Jul 9 14:37:17 2009
New Revision: 75163
URL: http://llvm.org/viewvc/llvm-project?rev=75163&view=rev
Log:
Remove some duplication.
Modified:
llvm/trunk/lib/CompilerDriver/Main.cpp
Modified: llvm/trunk/lib/CompilerDriver/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=75163&r1=75162&r2=75163&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/Main.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Main.cpp Thu Jul 9 14:37:17 2009
@@ -31,31 +31,29 @@
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 @@
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;
}
More information about the llvm-commits
mailing list