[llvm] r318122 - Add a move assignment operator to TempFile. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 16:31:28 PST 2017


Author: rafael
Date: Mon Nov 13 16:31:28 2017
New Revision: 318122

URL: http://llvm.org/viewvc/llvm-project?rev=318122&view=rev
Log:
Add a move assignment operator to TempFile. NFC.

Modified:
    llvm/trunk/include/llvm/Support/FileSystem.h
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=318122&r1=318121&r2=318122&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Nov 13 16:31:28 2017
@@ -712,6 +712,7 @@ public:
   static Expected<TempFile> create(const Twine &Model,
                                    unsigned Mode = all_read | all_write);
   TempFile(TempFile &&Other);
+  TempFile &operator=(TempFile &&Other);
 
   // Name of the temporary file.
   std::string TmpName;

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=318122&r1=318121&r2=318122&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Mon Nov 13 16:31:28 2017
@@ -761,10 +761,12 @@ std::error_code createUniqueFile(const T
 }
 
 TempFile::TempFile(StringRef Name, int FD) : TmpName(Name), FD(FD) {}
-TempFile::TempFile(TempFile &&Other) {
+TempFile::TempFile(TempFile &&Other) { *this = std::move(Other); }
+TempFile &TempFile::operator=(TempFile &&Other) {
   TmpName = std::move(Other.TmpName);
   FD = Other.FD;
   Other.Done = true;
+  return *this;
 }
 
 TempFile::~TempFile() { assert(Done); }




More information about the llvm-commits mailing list