diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-06-11 16:42:42 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-06-11 16:42:42 +0000 |
commit | a6fe345ac9613215237fa3fcbae4e34119d4ecf0 (patch) | |
tree | 0d9cfedc22da7824bd3265731b6e62f9fd327a28 /llvm/unittests/Support/Path.cpp | |
parent | 08200d6d26e98fce472fa530e980bc5dda5369d6 (diff) | |
download | bcm5719-llvm-a6fe345ac9613215237fa3fcbae4e34119d4ecf0.tar.gz bcm5719-llvm-a6fe345ac9613215237fa3fcbae4e34119d4ecf0.zip |
[Path] Set FD to -1 in moved-from TempFile
When moving a temp file, explicitly set the file descriptor to -1 so we
can never accidentally close the moved-from TempFile.
Differential revision: https://reviews.llvm.org/D63087
llvm-svn: 363083
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
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")); |