Frontend: Default to creating output files using temporary files + rename.

- This is a more reliable default, as it behaves better on failure and also
   ensures that we create *new* files (instead of reusing existing inodes). This
   is useful for other applications (like lldb) which want to cache inode's to
   know when a file has been rewritten.

llvm-svn: 151961
This commit is contained in:
Daniel Dunbar 2012-03-03 00:36:06 +00:00
parent b9c62c0773
commit ae77b3dfad
2 changed files with 6 additions and 1 deletions

View File

@ -572,6 +572,10 @@ public:
/// Create the default output file (from the invocation's options) and add it
/// to the list of tracked output files.
///
/// The files created by this function always use temporary files to write to
/// their result (that is, the data is written to a temporary file which will
/// atomically replace the target output on success).
///
/// \return - Null on error.
llvm::raw_fd_ostream *
createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "",

View File

@ -470,7 +470,8 @@ CompilerInstance::createDefaultOutputFile(bool Binary,
StringRef InFile,
StringRef Extension) {
return createOutputFile(getFrontendOpts().OutputFile, Binary,
/*RemoveFileOnSignal=*/true, InFile, Extension);
/*RemoveFileOnSignal=*/true, InFile, Extension,
/*UseTemporary=*/true);
}
llvm::raw_fd_ostream *