[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 02:03:18 PST 2017


klimek added inline comments.


================
Comment at: include/clang/Rewrite/Core/Rewriter.h:188-197
+  /// prewrite(FID) is called after all changes to FID have been written to a
+  /// temporary file, but before that temporary file is moved into FID's
+  /// location.  Windows's ReplaceFileW(to, from) internally creates (another)
+  /// temporary file and swaps the data streams of that file with the one of
+  /// |to| so that it's possible to replace an opened file.  However, if |to|
+  /// _was_ opened, the temp file now has that open data stream, and
+  /// ReplaceFileW() fails to delete it, causing a tempo file leak.  To fix,
----------------
llvm.org seems to be down, so I cannot access the original patch - but I'm somewhat opposed to making this interface more complex. If we have a coupling of MemoryBuffer to the Rewriter, can we make that explicit instead?


https://reviews.llvm.org/D30385





More information about the cfe-commits mailing list