// REQUIRES: shell
// RUN: rm -rf %t
// RUN: mkdir -p %t

// This is a reproducer for PR37091.
//
// Verify that no temporary files are left behind by the clang-tidy invocation.

// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy %s -- --target=mips64
// RUN: rmdir %t

Clean up tmp files when deleting Compilation objects
[Driver] Clean up tmp files when deleting Compilation objects

Summary:
In rL327851 the createUniqueFile() and createTemporaryFile()
variants that do not return the file descriptors were changed to
create empty files, rather than only check if the paths are free.
This change was done in order to make the functions race-free.

That change led to clang-tidy (and possibly other tools) leaving
behind temporary assembly files, of the form placeholder-*, when
using a target that does not support the internal assembler.

The temporary files are created when building the Compilation
object in stripPositionalArgs(), as a part of creating the
compilation database for the arguments after the double-dash. The
files are created by Driver::GetNamedOutputPath().

Fix this issue by cleaning out temporary files at the deletion of
Compilation objects.

This fixes https://bugs.llvm.org/show_bug.cgi?id=37091.

Reviewers: klimek, sepavloff, arphaman, aaron.ballman, john.brawn, mehdi_amini, sammccall, bkramer, alexfh, JDevlieghere

Reviewed By: aaron.ballman, JDevlieghere

Subscribers: erichkeane, lebedev.ri, Ka-Ka, cfe-commits

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

git-svn-id: a34e9779ed74578ad5922b3306b3d80a0c825546@333637 91177308-0d34-0410-b5e6-96231b3b80d8
