fix(cpp): emit generic_arg references for base-class template arguments

The C++ base_class_clause handler's `template_type` branch read the base
name (`sub.child_by_field_name("name")`) and emitted the `inherits` edge,
but never descended into the base's `template_argument_list`. As a result
`class Car : public Base<Dep>` emitted `Car -> Base` (inherits) yet dropped
the `Car -> Dep` generic_arg reference entirely.

The Java handler `_emit_java_parent_type` already emits these generic_arg
references for base-class type arguments; C++ was the asymmetric gap.

Fix: after emitting the `inherits` edge, grab the base's `arguments` field
(the `template_argument_list`) and run `_cpp_collect_type_refs` over each
named argument with the generic flag set, emitting a `references` edge
(context "generic_arg") per collected type, guarding target != class node.
`_cpp_collect_type_refs` already handles nested/qualified args, so
`Base<std::vector<Dep>>` is covered too.

Adds a templated base (`Connection<T>`) + derived class
(`PooledClient : public Connection<HttpClient>`) to tests/fixtures/sample.cpp
and a test mirroring the Java generic-parents test.
This commit is contained in:
Synvoya
2026-07-01 16:36:52 +01:00
committed by safishamsi
parent bb5e5192df
commit 21bcb436b5
3 changed files with 40 additions and 0 deletions
+11
View File
@@ -36,6 +36,17 @@ struct RetryingHttpClient : HttpClient {
int maxRetries;
};
template <typename T>
class Connection {
public:
T resource;
};
class PooledClient : public Connection<HttpClient> {
public:
int poolSize;
};
int main() {
HttpClient client("https://api.example.com");
std::string response = client.get("/users");