forked from OSchip/llvm-project
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
This commit is contained in:
parent
795da1c108
commit
f8412cdae9
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue