]> granicus.if.org Git - clang/commitdiff
Frontend: Default to creating output files using temporary files + rename.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 3 Mar 2012 00:36:06 +0000 (00:36 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 3 Mar 2012 00:36:06 +0000 (00:36 +0000)
 - 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151961 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInstance.h
lib/Frontend/CompilerInstance.cpp

index 4ee90dfb9cd21994f91018d4d653dd57ed89a733..ff0c30939a411e53d68904aa242f96f1a028aaa3 100644 (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 = "",
index a7855112e65de880908b802ac4085a646d3b7c27..bf3e3a8908d970a9e981757c6316053ee0c1aaca 100644 (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 *