[llvm] [ADT] Add a helper function to create iterators in DenseMap (NFC) (PR #155133)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 24 07:28:59 PDT 2025


================
@@ -257,22 +257,13 @@ class DenseMapBase : public DebugEpochBase {
   std::pair<iterator, bool> try_emplace(KeyT &&Key, Ts &&...Args) {
     BucketT *TheBucket;
     if (LookupBucketFor(Key, TheBucket))
-      return std::make_pair(makeIterator(TheBucket,
-                                         shouldReverseIterate<KeyT>()
-                                             ? getBuckets()
-                                             : getBucketsEnd(),
-                                         *this, true),
+      return std::make_pair(makeInsertIterator(TheBucket),
----------------
kuhar wrote:

I don't think there's much reason to use `make_pair` or `make_tuple` in C++17...  You can either do `return {a, b};` or `return pair(a, b);` -- I almost always use the former because it results in the correct pair/tuple type.

I realize this is pre-existing code, maybe we can clean this up in a follow-up PR.

https://github.com/llvm/llvm-project/pull/155133


More information about the llvm-commits mailing list