find_dead_code
Find C/C++ functions defined but never called anywhere in the codebase, using libclang index analysis. Returns dead or possibly_dead status with reasons, and filters to project code by default.
Instructions
Find C/C++ functions that are defined but never called — libclang-powered dead code detection across the entire indexed codebase. Distinguishes called from uncalled symbols globally, not just within a single file — text-based search cannot determine whether a function is actually reachable.
What "dead" means: zero references in the index — no call, no
function-pointer assignment, no indirect call site. This is a
single-layer reference check, NOT a reachability analysis from the
entry points (main, ISR, exported symbols): a function that only a
second dead function calls still has a reference, thus this tool does
not mark it. For transitive reachability, trace from your entry points
with find_callees_recursive.
The status field splits the results:
"dead"— no reference at all. Likely unused."possibly_dead"— assigned to a function pointer (Phase 1ref_kind="indirect"), but no call site through that pointer resolved (Phase 3). Unindexed code or a type-erased API can still call it. Treat it as uncertain, and check each hit withfind_indirect_targetsbefore you delete anything.
fw-context detects a constructor call through global/static object and
member-field initialization as an implicit_construct reference.
Known false positives remain: constructors from factories, ISRs,
virtual method overrides, and weak-aliased symbols. Always verify
before you delete.
project_only=True (default) excludes the SDK and vendor paths
through the is_project column, which follows the vendor_paths
and project_paths config. Set project_only=False to see the
vendor results too.
Read-only. No side effects. Requires the reference index
(fw-context index — refs on by default).
Args:
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.
limit: Maximum results of one page (default 100, max 200).
offset: Skip this many results. Reads the next page; the page
notice names the offset to use.
exclude_paths: Additional LIKE patterns to exclude (user-supplied
tool parameter, not config). E.g. ['lib/%'].
project_only: When True (default), filters to is_project = 1
symbols. Set False to see all results.
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:
list of dicts, each with: name, qualified_name, kind, signature,
file (str — absolute), line, status ("dead" or
"possibly_dead"), and reason (str — explains why the function
is classified as dead or possibly dead).
Never empty: one dict with ``info`` replaces an empty result.
Check that key first.
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. | |
| limit | No | Maximum results of one page (default 100, max 200). | |
| offset | No | Skip this many results. Reads the next page of a long report. | |
| 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. | |
| project_only | No | When True (default), auto-excludes SDK/vendor paths based on the detected build system and applies project config exclude_paths. Set False to see all results. | |
| 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. | |
| exclude_paths | No | Additional LIKE patterns to exclude. Merged with defaults from config. E.g. ['lib/%']. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |