Repository navigation
fix(cpp): a call on a dereferenced iterator or pointer, (*it)->Visit(), calls the method of what it points at - #2598
Merged
Conversation
…()`, calls the method of what it points at The extractor records `(*it)->Visit()` and `(*node).Weight()` by their bare names, which the name strategies then gave to whichever class had a method of that name (0.4-0.7 guesses), and a local a dereference sets, `auto first = *nodes.begin()`, had no type. `*x` and `x->` in C++ expression typing now dereference a container's iterator to its element as well as pointers and holders (cppDereferenced, used by cppExpressionType, cppMemberObject and cppChainInnerType), and a bare-name call written on `(*name)` (read at the call's column, where the receiver starts) is resolved on the dereferenced value's class by C++ lookup before the name strategies run: the method, or no project method for a library type, a template parameter's, or a class that lacks it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
colbymchenry
added a commit
that referenced
this pull request
Oct 15, 2026
…, `it->second.Flush()`, calls the value's method (#2601) 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 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 #2579: calls through a dereference.
The extractor records
(*it)->Visit()and(*node).Weight()by their bare names, because it can't spell a(*name)receiver. The name strategies then gave those calls to whichever class had a method of that name, at confidence 0.4–0.7. Examples:(*iter)->number()overconst FieldDescriptor*went to the C# generator'sFieldGeneratorBase::number;(*range_tombstone_iter_)->SeekToFirst()went to the caller's ownLevelIterator.Separately, a local set by a dereference,
auto first = *nodes.begin(), had no type.What changed:
cppDereferenced:*xandx->in C++ expression typing now dereference a container's iterator to its element, as well as pointers and holders. It's used bycppExpressionType,cppMemberObjectandcppChainInnerType. This types:auto first = *nodes.begin();auto& wal = *it;*it;->through iterators in chains and initializers (it->Child()->Visit()).The iterator part is fix(cpp): a
->call on a declared container iterator calls the element's method #2576's element reading, factored out ascppIteratorTarget.matchCppDereferencedCall, which runs before the name strategies: a bare-name call written on(*name)is resolved on the dereferenced value's class by C++ lookup.cppUtf8Columnis factored out ofcppImplicitReceiverfor that.Validation
__tests__/cpp-dereferenced-iterator-calls.test.ts(4 tests): all 4 fail on main and pass here.*xon iterators: 3 tests;x->in expressions: 1;x->in chains: 1;(*table)->ReadMeta,(*ptr)->key()and(*captured_stream)->…through double pointers keep their target, typed at 0.9.(*it)->Name()reachesReadOnlyMemTable;(*pointer)->GetOptions<…>reachesConfigurable;(*txn)->PutreachesTransaction;(*builder)->FinishreachesBlockBuilder; 5 ×bfile->PathName()onauto bfile = *iterreachBlobFile.(*log_writer)->AddRecordnow reacheslog::Writerrather thanBlobLogWriter;(*r)->use_direct_io()reachesFSSequentialFile,FSWritableFileandFSRandomAccessFile;(*txn)->CommitreachesTransactionrather thanPendingExpectedValue.range_del_agg->ShouldDelete(test_case.lookup_key, …), wheretest_case = *it, now picks theParsedInternalKeyoverload, as main already does for the identical range-for loop above it.(*handle).reset()on astd::unique_ptr*;(*id).data()on astd::arrayalias;(*lk).lock()/unlock(); two(*result)->IsInstanceOfonU**in a template.auto first_cfd = *compaction_queue_.begin().(*lhs_sub)->GetReflection()/New/CopyFromonMessage**now reachMessagerather thanAny;(*target)->GetPrototype()on aconst TypeInfo**reachesTypeInforather than the caller's own class.(*iter)->number()overconst FieldDescriptor*, whose accessors aren't indexed, had reached the C# generator;child_ptr.get()on astd::unique_ptrbound from*ithad reached python'sScopedPythonPtr::get.Remaining, out of scope: map iterators'
it->second.m(), which needsstd::pairmembers; and other receivers the extractor can't spell (arr_[0].Foo(),this->p_->Foo()).🤖 Generated with Claude Code