summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-08-24 18:36:22 +0000
committerMartin Storsjo <martin@martin.st>2018-08-24 18:36:22 +0000
commit4153e9fbb1562d765297fec58e903345c9f165c3 (patch)
tree6e2f3df0b3c69a585495e9aee8849697b5d98a1e /llvm
parent9920489a2aa2c73b4d757cde0de678a2d68ceab7 (diff)
downloadbcm5719-llvm-4153e9fbb1562d765297fec58e903345c9f165c3.tar.gz
bcm5719-llvm-4153e9fbb1562d765297fec58e903345c9f165c3.zip
[Support] Allow discarding a FileOutputBuffer without removing the memory mapping
Differential Revision: https://reviews.llvm.org/D51095 llvm-svn: 340634
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/FileOutputBuffer.h4
-rw-r--r--llvm/lib/Support/FileOutputBuffer.cpp6
2 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/FileOutputBuffer.h b/llvm/include/llvm/Support/FileOutputBuffer.h
index ee8cbb73087..68226ca5550 100644
--- a/llvm/include/llvm/Support/FileOutputBuffer.h
+++ b/llvm/include/llvm/Support/FileOutputBuffer.h
@@ -76,6 +76,10 @@ public:
/// 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) {}
diff --git a/llvm/lib/Support/FileOutputBuffer.cpp b/llvm/lib/Support/FileOutputBuffer.cpp
index 1214b5a0ba1..b8223126227 100644
--- a/llvm/lib/Support/FileOutputBuffer.cpp
+++ b/llvm/lib/Support/FileOutputBuffer.cpp
@@ -61,6 +61,12 @@ public:
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;
OpenPOWER on IntegriCloud