[PATCH] D36413: Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2019-03-13 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Note to self, this was for https://crbug.com/751225


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D36413/new/

https://reviews.llvm.org/D36413



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36413: Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2017-08-08 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r310376, thanks!


https://reviews.llvm.org/D36413



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36413: Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2017-08-07 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

This helps some tools that do things based on the output's extension.

For example, we got reports from users on Windows that have a tool that scan a 
build output dir (but skip .obj files). The tool would keep the "foo.obj-12345" 
file open, and then when clang tried to rename the temp file to the final 
output filename, that would fail. By making the tempfile end in ".obj.tmp", 
tools like this could now have a rule to ignore .tmp files.

This is a less ambitious reland of https://reviews.llvm.org/D36238


https://reviews.llvm.org/D36413

Files:
  lib/Frontend/CompilerInstance.cpp


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -759,9 +759,15 @@
 
   if (UseTemporary) {
 // Create a temporary file.
-SmallString<128> TempPath;
-TempPath = OutFile;
+// Insert - before the extension (if any), and because some tools
+// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
+// artifacts, also append .tmp.
+StringRef OutputExtension = llvm::sys::path::extension(OutFile);
+SmallString<128> TempPath =
+StringRef(OutFile).drop_back(OutputExtension.size());
 TempPath += "-";
+TempPath += OutputExtension;
+TempPath += ".tmp";
 int fd;
 std::error_code EC =
 llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -759,9 +759,15 @@
 
   if (UseTemporary) {
 // Create a temporary file.
-SmallString<128> TempPath;
-TempPath = OutFile;
+// Insert - before the extension (if any), and because some tools
+// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
+// artifacts, also append .tmp.
+StringRef OutputExtension = llvm::sys::path::extension(OutFile);
+SmallString<128> TempPath =
+StringRef(OutFile).drop_back(OutputExtension.size());
 TempPath += "-";
+TempPath += OutputExtension;
+TempPath += ".tmp";
 int fd;
 std::error_code EC =
 llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits