get_inheritance_chain
Return C++ class inheritance chains: direct bases and derived classes with access and virtual flags. Optionally walk full ancestor/descendant tree with cycle detection.
Instructions
Return the C++ inheritance chain for a class or struct — libclang-aware hierarchy. Resolves base/derived class relationships across all translation units, which single-file reading cannot do.
Shows direct base classes (what this inherits from) and direct derived classes (what inherits from this), along with access level and virtual flag for each edge.
When transitive=True, walks the full hierarchy up to all ancestors
and down to all descendants (bounded by max_depth). Uses BFS with
cycle detection to handle diamond inheritance.
For class members use get_class_members. For virtual method
override chains use get_method_overrides.
Read-only. No side effects.
Args:
class_name: Class or struct name to get inheritance information for.
E.g. 'UART_DRIVER' or 'comm::MODEM'.
project_root: Project root. Auto-detected if omitted.
project: Project name or project_id — call list_projects to get them. Use
it to ask about a project that is not the project of the current
directory. It is an alternative to project_root, which takes a root
path. Give one of the two, not both.
transitive: When True, walk the full inheritance tree both up
(ancestors) and down (descendants). Default: False (direct
bases and derived only).
max_depth: Maximum BFS depth for transitive walk (default 10).
The schema holds it between 1 and 50, thus a number outside
that range is REFUSED and not cut down to fit.
variant: Build variant (multi-build project). Omit to use
default_variant. One query answers for ONE build.
image: Sysbuild image within the variant. Required when the
variant holds several: each image is a separate program.
Returns: dict: { name, qualified_name, kind, file, line, bases: [{name, usr, access, is_virtual, file}], derived: [{name, usr, access, is_virtual, file}], all_bases: [...] (when transitive=True, ancestors sorted by depth), all_derived: [...] (when transitive=True, descendants sorted by depth) }
On failure the dict holds only ``error`` with the reason.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | No | Sysbuild image within the variant. Required when the variant holds several: each image is a separate program. | |
| project | No | Project name or project_id — call list_projects to get them. Use it to ask about a project that is not the project of the current directory. It is an alternative to project_root, which takes a root path. Give one of the two, not both. | |
| variant | No | Build variant (multi-build project). Omit to use default_variant. One query answers for ONE build. | |
| max_depth | No | Maximum BFS depth for transitive walk (default 10). | |
| class_name | Yes | Class or struct name to get inheritance information for. E.g. 'UART_DRIVER' or 'comm::MODEM'. | |
| transitive | No | When True, walk the full inheritance tree both up (ancestors) and down (descendants). Default: False (direct bases and derived only). | |
| project_root | No | Project root. Auto-detected if omitted. This field also accepts a project name or a project_id, but project is the clear field for those. |