dstenb created this revision.
dstenb added reviewers: klimek, sepavloff, arphaman.
Herald added a subscriber: cfe-commits.

In https://reviews.llvm.org/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 the Compilation object's temporary
file list before the object is deleted at end-of-scope in
stripPositionalArgs().

I am not very well-versed in Driver/Tooling, so I don't know if this
should be seen as a proper fix, or as a temporary workaround.
I at least assume that we want to use a race-free variant rather
than getPotentiallyUniqueTempFileName() in
Driver::GetNamedOutputPath().

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


Repository:
  rC Clang

https://reviews.llvm.org/D45686

Files:
  lib/Tooling/CompilationDatabase.cpp


Index: lib/Tooling/CompilationDatabase.cpp
===================================================================
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -299,6 +299,9 @@
     }
   }
 
+  // Remove temp files.
+  Compilation->CleanupFileList(Compilation->getTempFiles());
+
   if (CompileAnalyzer.Inputs.empty()) {
     ErrorMsg = "warning: no compile jobs found\n";
     return false;


Index: lib/Tooling/CompilationDatabase.cpp
===================================================================
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -299,6 +299,9 @@
     }
   }
 
+  // Remove temp files.
+  Compilation->CleanupFileList(Compilation->getTempFiles());
+
   if (CompileAnalyzer.Inputs.empty()) {
     ErrorMsg = "warning: no compile jobs found\n";
     return false;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D45686: [Tooling] C... David Stenberg via Phabricator via cfe-commits

Reply via email to