summaryrefslogtreecommitdiff
path: root/lib/Support/FileOutputBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/FileOutputBuffer.cpp')
-rw-r--r--lib/Support/FileOutputBuffer.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Support/FileOutputBuffer.cpp b/lib/Support/FileOutputBuffer.cpp
index 651e679f2cb5..2c7bf0435d88 100644
--- a/lib/Support/FileOutputBuffer.cpp
+++ b/lib/Support/FileOutputBuffer.cpp
@@ -32,6 +32,9 @@ FileOutputBuffer::FileOutputBuffer(std::unique_ptr<mapped_file_region> R,
: Region(std::move(R)), FinalPath(Path), TempPath(TmpPath) {}
FileOutputBuffer::~FileOutputBuffer() {
+ // Close the mapping before deleting the temp file, so that the removal
+ // succeeds.
+ Region.reset();
sys::fs::remove(Twine(TempPath));
}