summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Support/Path.cpp1
-rw-r--r--llvm/unittests/Support/Path.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 5312e1df3b6..c49260125db 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1125,6 +1125,7 @@ TempFile &TempFile::operator=(TempFile &&Other) {
TmpName = std::move(Other.TmpName);
FD = Other.FD;
Other.Done = true;
+ Other.FD = -1;
return *this;
}
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index 4eee8e923b7..f0e11b4e3f6 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -578,6 +578,7 @@ TEST_F(FileSystemTest, TempFileKeepDiscard) {
auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%");
ASSERT_TRUE((bool)TempFileOrError);
fs::TempFile File = std::move(*TempFileOrError);
+ ASSERT_EQ(-1, TempFileOrError->FD);
ASSERT_FALSE((bool)File.keep(TestDirectory + "/keep"));
ASSERT_FALSE((bool)File.discard());
ASSERT_TRUE(fs::exists(TestDirectory + "/keep"));
@@ -589,6 +590,7 @@ TEST_F(FileSystemTest, TempFileDiscardDiscard) {
auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%");
ASSERT_TRUE((bool)TempFileOrError);
fs::TempFile File = std::move(*TempFileOrError);
+ ASSERT_EQ(-1, TempFileOrError->FD);
ASSERT_FALSE((bool)File.discard());
ASSERT_FALSE((bool)File.discard());
ASSERT_FALSE(fs::exists(TestDirectory + "/keep"));
OpenPOWER on IntegriCloud