[llvm] [ADT] Refactor DenseMapIterator::operator-> (NFC) (PR #157227)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 22:43:23 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/157227
This patchs implement DenseMapIterator::operator-> in terms of
operator* to reduce code duplication.
>From 08e1080cb2a227123b9f8e01bc64c73f6e38abf3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 5 Sep 2025 00:35:01 -0700
Subject: [PATCH] [ADT] Refactor DenseMapIterator::operator-> (NFC)
This patchs implement DenseMapIterator::operator-> in terms of
operator* to reduce code duplication.
---
llvm/include/llvm/ADT/DenseMap.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 0650dc2044ca9..848e76feb20c6 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -1242,13 +1242,7 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
return Ptr[-1];
return *Ptr;
}
- pointer operator->() const {
- assert(isHandleInSync() && "invalid iterator access!");
- assert(Ptr != End && "dereferencing end() iterator");
- if (shouldReverseIterate<KeyT>())
- return &(Ptr[-1]);
- return Ptr;
- }
+ pointer operator->() const { return &operator*(); }
friend bool operator==(const DenseMapIterator &LHS,
const DenseMapIterator &RHS) {
More information about the llvm-commits
mailing list