https://llvm.org/bugs/show_bug.cgi?id=26125. The proposed patch is in the
bug attachment

Bug 26125 - Clang format creates unwanted temporary files when batching
processing on windows

# Summary
A file mapping object prevents the temp file from being deleted. This is a
100% repro on Windows.

# Details
When formatting a file in place, the original file is mapped into memory
for reading.

Later when trying to overwrite the changed file, kernel!ReplaceFile()
renames the original file to <filename>~RFxxxx.TMP, creates a new file with
<filename>, copies formatted content to it, and finally deletes
<filename>~RFxxxx.TMP. Because there is still a open file mapping section
to the original file (now with new file name <filename>~RFxxxx.TMP), delete
fails with 0xc0000121 - STATUS_CANNOT_DELETE, leaving the temp file
untouched after the clang-format operation.

# Fix
Releasing the file mapping object early allows deletefile to proceed
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to