[libcxx-commits] [PATCH] D120673: [demangler] Simplify SwapAndRestore

Nathan Sidwell via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 1 04:37:54 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe5c98e22fbbe: [demangler] Simplify SwapAndRestore (authored by urnathan).
Herald added a project: libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++abi.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120673

Files:
  libcxxabi/src/demangle/Utility.h
  llvm/include/llvm/Demangle/Utility.h


Index: llvm/include/llvm/Demangle/Utility.h
===================================================================
--- llvm/include/llvm/Demangle/Utility.h
+++ llvm/include/llvm/Demangle/Utility.h
@@ -163,7 +163,6 @@
 template <class T> class SwapAndRestore {
   T &Restore;
   T OriginalValue;
-  bool ShouldRestore = true;
 
 public:
   SwapAndRestore(T &Restore_) : SwapAndRestore(Restore_, Restore_) {}
@@ -172,20 +171,7 @@
       : Restore(Restore_), OriginalValue(Restore) {
     Restore = std::move(NewVal);
   }
-  ~SwapAndRestore() {
-    if (ShouldRestore)
-      Restore = std::move(OriginalValue);
-  }
-
-  void shouldRestore(bool ShouldRestore_) { ShouldRestore = ShouldRestore_; }
-
-  void restoreNow(bool Force) {
-    if (!Force && !ShouldRestore)
-      return;
-
-    Restore = std::move(OriginalValue);
-    ShouldRestore = false;
-  }
+  ~SwapAndRestore() { Restore = std::move(OriginalValue); }
 
   SwapAndRestore(const SwapAndRestore &) = delete;
   SwapAndRestore &operator=(const SwapAndRestore &) = delete;
Index: libcxxabi/src/demangle/Utility.h
===================================================================
--- libcxxabi/src/demangle/Utility.h
+++ libcxxabi/src/demangle/Utility.h
@@ -163,7 +163,6 @@
 template <class T> class SwapAndRestore {
   T &Restore;
   T OriginalValue;
-  bool ShouldRestore = true;
 
 public:
   SwapAndRestore(T &Restore_) : SwapAndRestore(Restore_, Restore_) {}
@@ -172,20 +171,7 @@
       : Restore(Restore_), OriginalValue(Restore) {
     Restore = std::move(NewVal);
   }
-  ~SwapAndRestore() {
-    if (ShouldRestore)
-      Restore = std::move(OriginalValue);
-  }
-
-  void shouldRestore(bool ShouldRestore_) { ShouldRestore = ShouldRestore_; }
-
-  void restoreNow(bool Force) {
-    if (!Force && !ShouldRestore)
-      return;
-
-    Restore = std::move(OriginalValue);
-    ShouldRestore = false;
-  }
+  ~SwapAndRestore() { Restore = std::move(OriginalValue); }
 
   SwapAndRestore(const SwapAndRestore &) = delete;
   SwapAndRestore &operator=(const SwapAndRestore &) = delete;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120673.412050.patch
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220301/243f1de4/attachment.bin>


More information about the libcxx-commits mailing list