[PATCH] D63087: [Path] Set FD to -1 in moved-from TempFile

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 09:39:55 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL363083: [Path] Set FD to -1 in moved-from TempFile (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63087?vs=203870&id=204091#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63087/new/

https://reviews.llvm.org/D63087

Files:
  llvm/trunk/lib/Support/Path.cpp
  llvm/trunk/unittests/Support/Path.cpp


Index: llvm/trunk/lib/Support/Path.cpp
===================================================================
--- llvm/trunk/lib/Support/Path.cpp
+++ llvm/trunk/lib/Support/Path.cpp
@@ -1125,6 +1125,7 @@
   TmpName = std::move(Other.TmpName);
   FD = Other.FD;
   Other.Done = true;
+  Other.FD = -1;
   return *this;
 }
 
Index: llvm/trunk/unittests/Support/Path.cpp
===================================================================
--- llvm/trunk/unittests/Support/Path.cpp
+++ llvm/trunk/unittests/Support/Path.cpp
@@ -578,6 +578,7 @@
   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 @@
   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"));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63087.204091.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190611/56d2a57d/attachment.bin>


More information about the llvm-commits mailing list