[llvm] 88ef274 - [ADT] Apply Rule of Five to StringTable::Iterator (#160815)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 08:43:52 PDT 2025
Author: Kazu Hirata
Date: 2025-09-26T08:43:48-07:00
New Revision: 88ef27463e56de7b80df5679c90bf32b81b4e104
URL: https://github.com/llvm/llvm-project/commit/88ef27463e56de7b80df5679c90bf32b81b4e104
DIFF: https://github.com/llvm/llvm-project/commit/88ef27463e56de7b80df5679c90bf32b81b4e104.diff
LOG: [ADT] Apply Rule of Five to StringTable::Iterator (#160815)
StringTable::Iterator has a user-defined copy assignment operator, a
defaulted copy constructor, and a defaulted move constructor.
This patch makes the copy assignment operator defaulted and adds a
defaulted move assignment operator to adhere to the Rule of Five while
making the operators constexpr.
Added:
Modified:
llvm/include/llvm/ADT/StringTable.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/StringTable.h b/llvm/include/llvm/ADT/StringTable.h
index 575b3c929e40c..9422a6da1ce8e 100644
--- a/llvm/include/llvm/ADT/StringTable.h
+++ b/llvm/include/llvm/ADT/StringTable.h
@@ -118,12 +118,8 @@ class StringTable {
constexpr Iterator(const Iterator &RHS) = default;
constexpr Iterator(Iterator &&RHS) = default;
- Iterator &operator=(const Iterator &RHS) {
- Table = RHS.Table;
- O = RHS.O;
- S = RHS.S;
- return *this;
- }
+ constexpr Iterator &operator=(const Iterator &RHS) = default;
+ constexpr Iterator &operator=(Iterator &&RHS) = default;
bool operator==(const Iterator &RHS) const {
assert(Table == RHS.Table && "Compared iterators for unrelated tables!");
More information about the llvm-commits
mailing list