[Support] Fix TempFile::discard to not leave behind temporary files

Moved the remove of the temporary file to after the close to avoid
remove failures caused by ETXTBSY errors.

This issue was seen when FileOutputBuffer falls back to an in memory
buffer due to the inability to mmap the on disk file. This occurred when
running LLD on an Ubuntu VM in VirtualBox on a Windows host attempting
to write the output to a VirtualBox shared folder.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354017 91177308-0d34-0410-b5e6-96231b3b80d8
1 file changed