Index: llvm/trunk/include/llvm/Support/FileOutputBuffer.h =================================================================== --- llvm/trunk/include/llvm/Support/FileOutputBuffer.h +++ llvm/trunk/include/llvm/Support/FileOutputBuffer.h @@ -76,6 +76,10 @@ /// deallocates the buffer and the target file is never written. virtual ~FileOutputBuffer() {} + /// This removes the temporary file (unless it already was committed) + /// but keeps the memory mapping alive. + virtual void discard() {} + protected: FileOutputBuffer(StringRef Path) : FinalPath(Path) {} Index: llvm/trunk/lib/Support/FileOutputBuffer.cpp =================================================================== --- llvm/trunk/lib/Support/FileOutputBuffer.cpp +++ llvm/trunk/lib/Support/FileOutputBuffer.cpp @@ -61,6 +61,12 @@ consumeError(Temp.discard()); } + void discard() override { + // Delete the temp file if it still was open, but keeping the mapping + // active. + consumeError(Temp.discard()); + } + private: std::unique_ptr Buffer; fs::TempFile Temp;