Recommit "Fix tmp files being left on Windows builds." with a fix for
authorAmy Huang <akhuang@google.com>
Wed, 2 Jun 2021 16:49:12 +0000 (09:49 -0700)
committerAmy Huang <akhuang@google.com>
Wed, 2 Jun 2021 23:50:37 +0000 (16:50 -0700)
commit9d070b2f4889887f9ce497592ef01df7b9601a1c
tree119b9464dc396cd324609dd35e33dc3893a4e88c
parent87c43f3aa99d778755c7f5420e955885f855ecad
Recommit "Fix tmp files being left on Windows builds." with a fix for
incorrect std::string use. (Also remove redundant call to
RemoveFileOnSignal.)

Clang writes object files by first writing to a .tmp file and then
renaming to the final .obj name. On Windows, if a compile is killed
partway through the .tmp files don't get deleted.

Currently it seems like RemoveFileOnSignal takes care of deleting the
tmp files on Linux, but on Windows we need to call
setDeleteDisposition on tmp files so that they are deleted when
closed.

This patch switches to using TempFile to create the .tmp files we write
when creating object files, since it uses setDeleteDisposition on Windows.
This change applies to both Linux and Windows for consistency.

Differential Revision: https://reviews.llvm.org/D102876

This reverts commit 20797b129f844d4b12ffb2b12cf33baa2d42985c.
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/CompilerInstance.cpp
llvm/lib/Support/Path.cpp
llvm/lib/Support/Windows/Path.inc