1 Commits

Author SHA1 Message Date
Colby Mchenry bb817d4538 fix(cpp): structured bindings and function wrappers give their types to calls on them (#2540)
Receiver inference had no type for a name a structured binding declares,
for what a `std::function` returns, or for a class member whose type is
written on the line above its name. rocksdb's MultiCfIteratorImpl writes
`for (auto& [cfh, iter] : cfh_iter_pairs_) { iter->Valid(); … }` over a
member declared across two lines as a
`std::vector<std::pair<ColumnFamilyHandle*, std::unique_ptr<Iterator>>>`;
the calls were guessed by the method's name.

- cppStructuredBindingType reads a binding's type at the name's place: an
  element of the range a range-for over the binding iterates, when the
  call is in its body, or of a declaration's initializer the calling
  function makes, a `std::pair` or `std::tuple` (cppBindingElements). A
  map's range elements are pairs of its key and value (CPP_LIBRARY_MAPS).
- cppStatementFrom reads a statement on to its `;`, for a binding's
  initializer and an `auto` local's.
- The declarator regex reads `std::function`, `std::move_only_function`,
  `std::copyable_function`, `absl::FunctionRef` and `absl::AnyInvocable`
  types, whose template argument is a function type, and
  cppExpressionType gives a call on such a variable what the function
  type returns (cppWrapperReturnType).
- cppDataMemberIn reads a member whose type is the whole line above its
  name (CPP_TYPE_LINE), so a default member initializer continued on the
  next line (`bool ready_ = flag_ &&` above `it_;`) isn't taken for one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 17:41:00 +00:00