diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2017-08-03 21:06:36 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2017-08-03 21:06:36 +0000 |
| commit | 09f4992c36dfadcacd62971cb8c1c0bdbe393cc2 (patch) | |
| tree | dd1e4d68e732e92b302bc156e9f939ab335366e3 /clang/lib | |
| parent | 33eee1911acd905732325b405fb9be58967ec44a (diff) | |
| download | bcm5719-llvm-09f4992c36dfadcacd62971cb8c1c0bdbe393cc2.tar.gz bcm5719-llvm-09f4992c36dfadcacd62971cb8c1c0bdbe393cc2.zip | |
Use "foo-12345.o" instead of "foo.o-12345" as temporary file name.
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", tools
like this will now skip the temp files as well.
https://reviews.llvm.org/D36238
llvm-svn: 309984
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index bb6a665cb45..d0c1a974aff 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -759,9 +759,13 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile( if (UseTemporary) { // Create a temporary file. - SmallString<128> TempPath; - TempPath = OutFile; + // Insert -%%%%%%%% before the extension (if any), so that tools doing + // things based on the file extension do the right thing. + StringRef OutputExtension = llvm::sys::path::extension(OutFile); + SmallString<128> TempPath = + StringRef(OutFile).drop_back(OutputExtension.size()); TempPath += "-%%%%%%%%"; + TempPath += OutputExtension; int fd; std::error_code EC = llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath); |

