diff options
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index bb6a665cb45..740dabea45a 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -759,9 +759,15 @@ 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), 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); |