Skip to content

fix(extraction): strip template args from out-of-line C++ method qualifiers (#1286)#1287

Open
Dshuishui wants to merge 1 commit into
colbymchenry:mainfrom
Dshuishui:fix/cpp-oo-template-method-qualifier
Open

fix(extraction): strip template args from out-of-line C++ method qualifiers (#1286)#1287
Dshuishui wants to merge 1 commit into
colbymchenry:mainfrom
Dshuishui:fix/cpp-oo-template-method-qualifier

Conversation

@Dshuishui

Copy link
Copy Markdown

Fixes #1286.

Problem

stripCppTemplateArgs (added in #1043 to drop <…> from templated base-class refs so extends resolves) isn't applied to method qualifiers. An out-of-line template method keeps the class template params in qualified_name:

template <typename T> class Box { public: T get() const; };
template <typename T> T Box<T>::get() const { /* ... */ }
// → qualified_name = "Box<T>::get"   (expected "Box::get")
  • name is already clean (get); only the qualifier leaks.
  • Inline method bodies are unaffected (Box::get) — the same method got a different qualified_name depending on where it's defined.
  • Long/multi-line template params (ICU capi_helper.h shape) push the qualified_name past NAME_MAX (255) → consumers deriving a filename hit "File name too long".
  • Same failure mode Support for C++ classes inheriting templated classes in C++ #1043 fixed for extends: name-matcher compares the qualifier before the last ::, and Box<T> ≠ the class node Box.

Fix

Apply the existing stripCppTemplateArgs to the receiver in extractCppReceiverType, before the :: split (also tolerates :: inside template args like Box<std::string>::get). Reuses the #1043 helper.

Tests

…ifiers (colbymchenry#1286)

An out-of-line template method definition (`template<typename T> T Box<T>::get()`)
recorded its class qualifier as the full instantiation `Box<T>`, so the method's
qualified_name came out as `Box<T>::get`. That never name-matched the class node
indexed as the bare `Box` (the same failure mode colbymchenry#1043 fixed for templated base
classes), and with long / multi-line template parameters the qualified_name could
exceed the 255-byte filename limit — a consumer deriving a filename from it hits
"File name too long".

Apply the existing stripCppTemplateArgs helper to the receiver in
extractCppReceiverType, before splitting on `::` (which also tolerates `::` inside
template args). Inline method bodies were already unaffected.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

C++: out-of-line template method qualified_name keeps template params (Box<T>::get), can overflow NAME_MAX

1 participant