diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
commit | cd749a9c07f1de2fb8affde90537efa4bc3e7c54 (patch) | |
tree | b21f6de4e08b89bb7931806bab798fc2a5e3a686 /lib/CompilerDriver/Main.cpp | |
parent | 72621d11de5b873f1695f391eb95f0b336c3d2d4 (diff) | |
download | FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.zip FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.tar.gz |
Update llvm to r84119.
Diffstat (limited to 'lib/CompilerDriver/Main.cpp')
-rw-r--r-- | lib/CompilerDriver/Main.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp index c9c0413..3e1fc9f 100644 --- a/lib/CompilerDriver/Main.cpp +++ b/lib/CompilerDriver/Main.cpp @@ -31,20 +31,29 @@ namespace { sys::Path getTempDir() { sys::Path tempDir; + // The --temp-dir option. + if (!TempDirname.empty()) { + tempDir = TempDirname; + } // 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; } @@ -53,17 +62,18 @@ namespace { int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) { int ret; const sys::Path& tempDir = getTempDir(); + bool toDelete = (SaveTemps == SaveTempsEnum::Unset); 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; } |