merge: reconcile upstream through 1753472a
C++ calls and object creation now link to the method or class C++ itself would pick in 15 more cases. On nlohmann/json this removes 1,045 links into other source files' own declarations while every precision case still holds.
This merges upstream main through 1753472a (keeping upstream as the second parent) and ports its 15 C++ fixes to the native resolver. Upstream made them in TypeScript files the fork deleted; their upstream versions were the porting spec, and upstream's tests were the acceptance bar.
Upstream changes
- #2536 Declarations with a qualifier or annotation around the name (
Iterator* const iter,Printer* PROTOBUF_NONNULL p,imm_ GUARDED_BY(mutex_)) give their type to calls: 20bdbed8. - #2537 A bare call in a gtest
TEST_F/TEST_Pbody reaches the fixture's method: 20bdbed8. One assertion keeps the fork's no-guess result (see below). - #2538 A call or type name never links to what only another source file can see: dc2289f6.
- #2539
->onabsl::StatusOr/optional/NoDestructorreaches the held class, and a using-declared member of a dependent base is found: 20bdbed8. - #2540 Structured bindings and
std::functionresults give their types to calls: 20bdbed8. - #2541 A call to an overloaded method takes the overload its arguments fit: 20bdbed8.
- #2542 A nested class defined out of line is indexed under its name (in the merge commit's walker change), and object creation links to the class C++ lookup finds: 884719f6, follow-up 9d5b66dc.
- #2548 A call through a class reaches that class's own or inherited method only: 1b30d192. One assertion keeps the fork's no-guess result.
- #2549 An alias that names a class through a derived class leads to the class a base declares: 884719f6.
- #2551 A gtest body finds its fixture's types first, and a function's local class is seen only inside that function: 884719f6.
- #2552 Block comments and string contents are blanked before declarations are read line by line: f92479d4.
- #2553 Comparisons and shifts in arguments, and bracket pairing in declared template types: no change needed; the fork reads arguments from the syntax tree, and the upstream tests pass.
- #2554
nullptrpicks thestd::nullptr_toverload, and no call links to a deleted overload: 20bdbed8. - #2555 A receiver declared as a pointer to a class template over two lines has its type read: b9510f0e.
- #2556 A member template called with explicit template arguments returns the type the template's parameter takes: 72e973ae.
Where the fork differs
- Two upstream assertions expect a call whose receiver type can't be read to be guessed from the receiver's name (0.7 and 0.8). The fork leaves such calls unlinked, as README's "About this fork" already records, so those assertions state the fork's result with the reason beside them (7e5e1bab).
- Comparing edges against the base on nlohmann/json showed 233 constructions reaching
tests/abi/include/nlohmann/json_v3_10_5.hpp, an old copy of the library. That copy spellsnamespace nlohmann {out, while the real headers open the namespace with a macro. Object creation now sees a header under a test directory only from inside that directory's tree or through an#include. A member of an alias the lookup can't follow gets no edge only when the alias names astd::type; otherwise it goes to the name strategies as before (9d5b66dc, with a regression test that fails without the fix).
Verification
- All 43 C++ test files (437 tests) pass, including 18 upstream C++ test files (118 tests), the fork's regression tests for the test-directory header rule, and
cpp-declarator-edge-cases(4 tests) and one local-callable test added for review findings (666cd744). - Golden dumps re-baselined (b5d16476): in
torture-multilang.dump, 11 C++instantiatesedges keep their targets and move from 0.4/0.9exact-matchto 0.9qualified-name. eval:precision, this branch against the base dfdf4a3f built the same way:- json: 11/11 absent and 7/7 present held on both. Edges go from 29,613 to 28,749. Of 1,063 removed, 1,045 had pointed into another source file's own declarations (#2538); of the other 18, 12 now follow an alias to the class it names and 6 had pointed to unrelated namesakes or the old copy. 199 were added, mostly typed member calls such as
basic_json::type. - jq (C): identical edges (7,784).
- json: 11/11 absent and 7/7 present held on both. Edges go from 29,613 to 28,749. Of 1,063 removed, 1,045 had pointed into another source file's own declarations (#2538); of the other 18, 12 now follow an alias to the class it names and 6 had pointed to unrelated namesakes or the old copy. 199 were added, mostly typed member calls such as
- Full suite (
npx vitest run) on 666cd744, which includes the merge offork/consolidated(ce0c73db): 719 files passed; 9,050 tests passed, 39 skipped, exit 0; the log has no panic or unhandled error. cargo clippy --release --lib -- -D warningsandnpx tscpass on 666cd744;npm run check:agent-docspasses. The precision numbers above were re-run on 666cd744 with the same result (json 28,749 edges, 11/11 and 7/7 held; jq 7,784).
README rows checked: the upstream merge point (already 1753472a); the C++ rows on aliases, smart-pointer holders, auto locals and members (the no-guess policy), and namespace lookup in the include closure. Added one row for the test-directory header rule. CHANGELOG keeps upstream's 15 bullets and adds one fork bullet for the two differences above. No docs-site page mirrors these rows.
Not covered: precision runs on the other C++ corpora named in upstream's commits (rocksdb, protobuf, leveldb, fmt) are not in this repository's precision set; only json and jq were run. The removed kernel-ccpp-parity test, which upstream extended, stays deleted with the WASM parser; cpp-written-scope-class-names covers its new case.
Summary by cubic
Merges upstream main through 1753472a, porting its 15 C++ resolution fixes to the native resolver so C++ calls and object creation link to the method or class C++ lookup would pick. On nlohmann/json this removes 1,045 links that pointed into other source files' own declarations.
What's ported
- Receiver types are read through qualifiers, annotations, structured bindings,
std::functionwrappers, and multi-line declarations (#2536, #2540, #2555). - Gtest
TEST_F/TEST_Pbodies resolve bare calls and type names through their fixture (#2537, #2551). ->onabsl::StatusOrand similar holders reaches the held class; using-declared members of dependent bases are found (#2539).- Calls and type names never link to what only another translation unit can see (#2538, #2548).
- Overloads are picked by argument types,
nullptrfitsstd::nullptr_t, and deleted overloads are used only when nothing else fits (#2541, #2554). - Out-of-line nested classes are indexed under their written scope, and constructions resolve to the class C++ finds (#2542, #2549).
- Member templates with explicit arguments give their return type to
autolocals (#2556). - Block comments and string contents are blanked before declarations are read line by line (#2552).
- Review findings are folded in: bare calls aren't typed from inherited or fixture methods when a local callable shadows them, base-class types are found only in included files, and qualifier/annotation edge cases (
__restrict, annotation macros without arguments, quoted template characters) are read correctly. The deleted-overload test now deletes the double overload and calls with an int so the fixture is well-formed C++.
Where the fork differs from upstream
- Two upstream tests expect unreadable receiver types to be guessed from the receiver's name; the fork leaves those calls unlinked, as README records.
- A header under a test directory is visible only from inside that tree or through
#include, keeping constructions from reaching an old vendored copy of nlohmann/json. - The set of files a C++ file sees is kept one file at a time; constructions of a file resolve together, so memory no longer grows with files times headers.
Summary by CodeRabbit
- New Features
- C++ call and construction links now resolve more accurately across overloads, templates, aliases, inherited members, structured bindings, supported library holders, and test fixtures.
- C and C++ references now respect source-file visibility, included headers, local scope, and test-directory header visibility.
- Bug Fixes
- Improved handling of qualified nested classes, multiline declarations, annotations, comments, and string literals.
- Calls with unknown receiver types or unrelated same-named declarations are less likely to receive incorrect links.
- Documentation
- Updated the documented upstream baseline and C++ resolution behavior.