get_inheritance_chain
Retrieve a C++ class or struct inheritance hierarchy across translation units, showing base and derived classes with access and virtual flags; optionally walk all ancestors and descendants.
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.
limit: Maximum classes in all_bases and in all_derived on
one page (default 100, max 500). Only with transitive=True.
offset: Skip this many classes in all_bases and in
all_derived. One offset pages the two lists together.
variant: Variant of the build (a board, or a PlatformIO
environment). On a project of more than one build, give the
arguments of one build as the refusal lists them: the
variant, the image, or the two. fw-context does not select a
build. One query answers for ONE build.
image: Image of the build: a separate program, such as the
application or the bootloader. Give it when the build has an
image name.
Returns: dict: { name, qualified_name, kind, file, line, bases: [{name, usr, access, is_virtual, file}], derived: [{name, usr, access, is_virtual, file}], all_bases: [{name, usr, access, is_virtual, depth, file, kind}] (when transitive=True, ancestors sorted by depth, then name), all_derived: [...] (when transitive=True, descendants, same shape) }
With ``transitive=True`` each of the two lists is one page, and
``all_bases_page`` and ``all_derived_page`` hold its page notice
``{total, offset, shown, more, hint}``. A hierarchy below a root
class of a framework can hold thousands of classes.
When a file of the answer changed after the last index run, the
dict adds ``stale`` (True) and ``stale_warning`` (str).
On failure the dict holds ``error`` with the reason.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | No | Image of the build: a separate program, such as the application or the bootloader. On a project of more than one build, give it when that build has an image name, as the refusal lists it. | |
| limit | No | Maximum classes in all_bases and in all_derived on one page (default 100, max 500). Only with transitive=True. | |
| offset | No | Skip this many classes in all_bases and in all_derived. Reads the next page of a large hierarchy. Only with transitive=True. | |
| 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 | Variant of the build (a board, or a PlatformIO environment). On a project of more than one build, give the arguments of one build as the refusal lists them: the variant, the image, or the two. fw-context does not select a build for you. 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. |