Repository navigation
fix(cpp): a call on the member of the pair a map's iterator points at, it->second.Flush(), calls the value's method - #2601
Merged
Conversation
…, `it->second.Flush()`, calls the value's method The extractor records `it->second.Flush()`, `kv.second.Flush()` and `(*it).first.Print()` by their bare names, which the name strategies gave to whichever class had a method of that name — 45 `std::string::c_str()` calls went to googletest's `FilePath::c_str` — and a local such a member initializes (`auto& v = it->second`) had no type. `x.first` / `x.second` (and `->`) on a `std::pair` now type as the pair's elements in C++ expression typing (cppPairMember), so a map's iterator, range-for element or declared pair reaches its key and value, and #2598's bare-name receiver reader also takes `name->second`, `name.first` and `(*name).second`. A member typed by another class template's parameter (`CoreLocalArray<T>::AccessElementAndIndex()`'s `std::pair<T*, size_t>`) goes on as before: only the calling function's own template parameter names no particular class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the follow-up left after #2598: calls through the key or value of a map's iterator, and through the members of a
std::pairgenerally.The extractor records
it->second.Flush(), a range-for'skv.second.Flush()and(*it).first.Print()by their bare names. The name strategies then gave those calls to whichever class had a method of that name. Examples:pair.first.c_str()calls onstd::strings all went to googletest'sFilePath::c_str;kv.second->GenerateMembers(…)went toImmutableEnumFieldGeneratorinstead ofOneofGenerator.Separately, a local set from such a member (
auto& v = it->second) had no type.What changed:
cppPairMember:x.first/x.second(and->) on astd::pairnow type as the pair's elements in C++ expression typing. So a map's iterator, a range-for element, a declared pair, or a pair a method returns all reach their key and value. This covers the receiver forms below,auto& v = it->second, and range expressions likestats_history_.begin()->second.(*it)->Visit(), calls the method of what it points at #2598's bare-name receiver reader (nowcppUnspelledReceiver/matchCppUnspelledReceiverCall) also takesname->second,name.firstand(*name).second.(*this)is still left tocppImplicitReceiver.first/secondmember, so plainthis->Foo()calls are untouched.CoreLocalArray<T>::AccessElementAndIndex(), which returns astd::pair<T*, size_t>. The first A/B caught exactly that: rocksdb'sp.first->GetUncompressData(idx)lost its correct link, and the guard restores it.Validation
__tests__/cpp-map-iterator-calls.test.ts(5 tests): 3 fail on main and pass here. The 2 guards pass on both: another template's parameter, andthis->Flush().name->secondreceivers: 3;(*name).secondreceivers: 1;std::string, container, smart pointer,std::optionalorweak_ptrthat had been guessed onto project methods (c_str,size,data,find,get,lock,has_value, …). For example, main'sfilters.size()reachedSlice::sizeat 0.9, butfiltersisit->secondof a string-to-string map.Slicekeys and values (entry.first.ToString()),HistogramStat,RangeDelAggregator::StripeRep,Snapshot,TrackedKeyInfo,InternalKey, and range-fors over a pair's member (ObjectLibrary::Entry).batch_and_status.first→WriteBatch;wal_and_status->first→log::Writer;pair.second->Timestamp()→cassandra::ColumnBase;range_buffer;Timer::FunctionInfo;OptionTypeInfo::AreEqualByNameoverload, now thestd::stringone, matchingiter->secondof a string map.p.second->file(),e.second->options()), which aren't indexed;ExtensionSet::Extension;OneofGenerator,UnknownField;Remaining, out of scope: element access the extractor drops (
m[k].Foo(),arr_[0].Foo()), andm.at(k).Foo()chains, which would need library containers' element-returning members.🤖 Generated with Claude Code