[clang-tools-extra] r333637 - [Driver] Clean up tmp files when deleting Compilation objects

David Stenberg via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 02:05:22 PDT 2018


Author: dstenb
Date: Thu May 31 02:05:22 2018
New Revision: 333637

URL: http://llvm.org/viewvc/llvm-project?rev=333637&view=rev
Log:
[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

Added:
    clang-tools-extra/trunk/test/clang-tidy/pr37091.cpp

Added: clang-tools-extra/trunk/test/clang-tidy/pr37091.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/pr37091.cpp?rev=333637&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/pr37091.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/pr37091.cpp Thu May 31 02:05:22 2018
@@ -0,0 +1,10 @@
+// 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




More information about the cfe-commits mailing list