llvm-project/llvm
Martin Storsjö 177176f75c [Support] [Windows] Manually clean up temp files if not setting delete disposition
Since D81803 / 79657e2339, temp files
created on network shares don't set "Disposition.DeleteFile = true".
This flag normally takes care of removing the temp file both if the
process exits abnormally (either crashing or killed externally), and
when the file is closed cleanly.

For network shares, we voluntarily choose to not set the flag, and
if the operation to inspect the file handle (as a prerequisite to
setting the flag since 79657e2339)
fails we also error out. In both of these cases, we can at least make
sure to remove the temp files when they are closed cleanly.

Adjust the semantics of "OF_Delete" to not set the delete
disposition, but only set the access mode for allowing deletion.
Move the call to setDeleteDisposition into TempFile::create,
where we can check if it failed, and if it did, set a flag noting
that the file should be removed manually at the end.

This does leak files on crash, but at least doesn't leak files
in regular successful runs. (Technically, the alternative codepath
could use the RemoveFileOnSignal function, but that might complicate
the TempFile implementation further.)

This fixes https://github.com/mstorsjo/llvm-mingw/issues/233 and
https://bugs.llvm.org/show_bug.cgi?id=52080.

Differential Revision: https://reviews.llvm.org/D111875
2021-10-28 10:33:37 +03:00
..
benchmarks
bindings
cmake
docs
examples
include [Support] [Windows] Manually clean up temp files if not setting delete disposition 2021-10-28 10:33:37 +03:00
lib [Support] [Windows] Manually clean up temp files if not setting delete disposition 2021-10-28 10:33:37 +03:00
projects
resources
runtimes
test [CSSPGO] Trim cold base profiles for the CS preinliner. 2021-10-27 22:50:27 -07:00
tools [CSSPGO] Trim cold base profiles for the CS preinliner. 2021-10-27 22:50:27 -07:00
unittests Revert "[IR] `IRBuilderBase::CreateAdd()`: short-circuit `x + 0` --> `x`" 2021-10-27 22:21:37 +03:00
utils utils/release: Add script for building release documentation 2021-10-27 12:56:55 -07:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.