Skip to content

fix(extraction): correct C++ reference-return and conversion-operator method names#1096

Merged
colbymchenry merged 2 commits into
mainfrom
fix/cpp-ref-return-and-conversion-operator-names
Jul 1, 2026
Merged

fix(extraction): correct C++ reference-return and conversion-operator method names#1096
colbymchenry merged 2 commits into
mainfrom
fix/cpp-ref-return-and-conversion-operator-names

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Context

While validating the #1093 forward-declaration fix against real Unreal Engine repos (tomlooman/ActionRoguelike, PanicPetal/ALS-Community), a name-quality scan surfaced two pre-existing C++ name-extraction bugs. Neither is caused by #1093 — this fix is independent.

Bugs fixed

1. Reference-returning methods/functions named after the whole declarator.
const int& getRef() const { … } parses with a reference_declarator wrapping the function_declarator. extractName unwrapped pointer_declarator but not reference_declarator, so the method was named "& getRef() const" instead of getRef — breaking name search and caller linkage. This is ubiquitous in UE gameplay headers (e.g. const FGameplayTagContainer& GetActiveTags() const). Fix: unwrap the reference wrapper alongside the pointer wrapper.

2. Conversion operators named with their full declarator.
operator EALSMovementState() const was indexed verbatim instead of operator EALSMovementState, so it didn't match the symbolic-overload style (operator+) and carried () const noise. Fix: name the operator_cast declarator operator <type>.

Scope / safety

Both changes are additive and C++-scoped — reference_declarator and operator_cast are C++ grammar node types, so no other language is affected (full 401-test extraction suite passes). Controls confirmed unchanged: pointer returns (int* f()getPtr), value returns (int f() constgetVal), out-of-line reference returns (resolve via the qualified-name hook), and symbolic operator overloads (operator+, operator[]).

Validation

Before/after re-index of both UE repos: every reference-returning getter and conversion operator now carries a clean name; a name-mangle scan drops to zero real mangles. Six regression tests added (extraction.test.ts).

Known follow-up (not in this PR)

A separate, messier case remains: an unknown function-level macro before an unrecognized return type (e.g. UE's FORCEINLINE FString GetEnumerationToString(...)) throws tree-sitter into error recovery and leaks the return type into the name (FString GetEnumerationToString). That's the same family as #946/#1061 (macro misparse) and deserves its own focused fix + macro curation.

🤖 Generated with Claude Code

colbymchenry and others added 2 commits July 1, 2026 06:49
… method names

Two pre-existing C++ name-extraction bugs surfaced while validating the #1093
forward-declaration fix against real Unreal Engine repos (ActionRoguelike, ALS):

1. Inline methods/functions returning a reference were named after the whole
   declarator. `const int& getRef() const {…}` parses with a reference_declarator
   wrapping the function_declarator; extractName unwrapped pointer_declarator but
   not reference_declarator, so the method was named "& getRef() const" instead
   of "getRef" — polluting search and breaking caller linkage. Ubiquitous in UE
   headers (`const FGameplayTagContainer& GetActiveTags() const`). Now the
   reference wrapper is unwrapped alongside the pointer wrapper.

2. User-defined conversion operators were named with their full declarator —
   `operator EALSMovementState() const` — instead of `operator EALSMovementState`,
   so they didn't match the symbolic-overload style (`operator+`) and carried
   `() const` noise. The operator_cast declarator is now named `operator <type>`.

Both are additive and C++-scoped (reference_declarator / operator_cast are C++
grammar nodes). Pointer, value, and out-of-line reference returns, and symbolic
operator overloads, are unchanged. Six regression tests added.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…me fixes (#1096)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@colbymchenry colbymchenry merged commit 712a406 into main Jul 1, 2026
@colbymchenry colbymchenry deleted the fix/cpp-ref-return-and-conversion-operator-names branch July 1, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant