[PATCH] D120673: [demangler] Simplify SwapAndRestore
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 1 03:46:15 PST 2022
urnathan updated this revision to Diff 412036.
urnathan added a comment.
Fix formating
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.412036.patch
Type: text/x-patch
Size: 2052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/3478633d/attachment.bin>
More information about the llvm-commits
mailing list