summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-18 19:34:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-18 19:34:39 +0000
commite627c1cc0f31b4427e3cdcc863ec7a384c309bf9 (patch)
treef416ca227c14a82603f41bb2aa91b804938322dc /clang/lib/Driver/Driver.cpp
parentf3d5e6c32fe7f88ce4a95cabc8ff33da8f926854 (diff)
downloadbcm5719-llvm-e627c1cc0f31b4427e3cdcc863ec7a384c309bf9.tar.gz
bcm5719-llvm-e627c1cc0f31b4427e3cdcc863ec7a384c309bf9.zip
Driver: Construct temporary file names.
- This is still suboptimal, but should at least be workable. llvm-svn: 67223
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 49a4dca54ce..9d913a1601d 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -808,11 +808,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
// Output to a temporary file?
if (!AtTopLevel && !C.getArgs().hasArg(options::OPT_save_temps)) {
- // FIXME: Get temporary name.
- std::string Name("/tmp/foo");
- Name += '.';
- Name += types::getTypeTempSuffix(JA.getType());
- return C.addTempFile(C.getArgs().MakeArgString(Name.c_str()));
+ std::string TmpName =
+ GetTemporaryPath(types::getTypeTempSuffix(JA.getType()));
+ return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
}
llvm::sys::Path BasePath(BaseInput);
@@ -861,6 +859,20 @@ llvm::sys::Path Driver::GetProgramPath(const char *Name,
return llvm::sys::Path(Name);
}
+std::string Driver::GetTemporaryPath(const char *Suffix) const {
+ // FIXME: This is lame; sys::Path should provide this function (in
+ // particular, it should know how to find the temporary files dir).
+ std::string Error;
+ llvm::sys::Path P("/tmp/cc");
+ if (P.makeUnique(false, &Error)) {
+ Diag(clang::diag::err_drv_unable_to_make_temp) << Error;
+ return "";
+ }
+
+ P.appendSuffix(Suffix);
+ return P.toString();
+}
+
const HostInfo *Driver::GetHostInfo(const char *Triple) const {
llvm::PrettyStackTraceString CrashInfo("Constructing host");
// Dice into arch, platform, and OS. This matches
OpenPOWER on IntegriCloud