diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-07-15 21:54:29 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-07-15 21:54:29 +0000 |
commit | f8412cdae978c6343755ecf5340204cc3b280f12 (patch) | |
tree | 648444c80eb4eb908711f2ceb21fc62292ef6e2b /clang/lib/Driver/Driver.cpp | |
parent | 795da1c1081bf6aee68f004e11d855954abfaa77 (diff) | |
download | bcm5719-llvm-f8412cdae978c6343755ecf5340204cc3b280f12.tar.gz bcm5719-llvm-f8412cdae978c6343755ecf5340204cc3b280f12.zip |
Prevent the -save-temps flag from modifying the input file if the input filename
conflicts with a to be produced temp filename.
rdar://9724657
llvm-svn: 135308
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 3a78b6a988f..616207bf761 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1252,6 +1252,15 @@ const char *Driver::GetNamedOutputPath(Compilation &C, NamedOutput = C.getArgs().MakeArgString(Suffixed.c_str()); } + // If we're saving temps and the temp filename conflicts with the input + // filename, then avoid overwriting input file. + if (!AtTopLevel && C.getArgs().hasArg(options::OPT_save_temps) && + NamedOutput == BaseName) { + std::string TmpName = + GetTemporaryPath(types::getTypeTempSuffix(JA.getType())); + return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str())); + } + // As an annoying special case, PCH generation doesn't strip the pathname. if (JA.getType() == types::TY_PCH) { llvm::sys::path::remove_filename(BasePath); |