Differential Revision: https://reviews.llvm.org/D51095
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340634
91177308-0d34-0410-b5e6-
96231b3b80d8
/// 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) {}
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<fs::mapped_file_region> Buffer;
fs::TempFile Temp;