Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2022-02-28 23:04:37 +0300
committerNathan Sidwell <nathan@acm.org>2022-03-01 15:37:24 +0300
commite5c98e22fbbe3c3eb5f2c782d0789098afc81518 (patch)
treebecf0b04f9803eed105479f168dfc17feb6b5aff /libcxxabi/src/demangle
parent3cdc1c155b40897a17d7fd61092d2f6fd21fb7ef (diff)
[demangler] Simplify SwapAndRestore
The SwapAndRestore class is over engineered. Nothing makes use of the early restoration machinery. Let's just remove that cognative burdon. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D120673
Diffstat (limited to 'libcxxabi/src/demangle')
-rw-r--r--libcxxabi/src/demangle/Utility.h16
1 files changed, 1 insertions, 15 deletions
diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h
index 21e5efb18542..f8190b81332a 100644
--- a/libcxxabi/src/demangle/Utility.h
+++ b/libcxxabi/src/demangle/Utility.h
@@ -163,7 +163,6 @@ public:
template <class T> class SwapAndRestore {
T &Restore;
T OriginalValue;
- bool ShouldRestore = true;
public:
SwapAndRestore(T &Restore_) : SwapAndRestore(Restore_, Restore_) {}
@@ -172,20 +171,7 @@ public:
: 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;