find_dead_code
Identify C/C++ functions defined but never called using libclang-based dead code detection across the entire indexed codebase, distinguishing truly dead functions from those possibly called via function pointers.
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.
Returns two categories of results, each with a status field:
"dead"— no references at all (neither calls nor function pointer assignments). Likely unused."possibly_dead"— the function is assigned to a function pointer (Phase 1ref_kind="indirect") but no call site through that pointer was resolved (Phase 3). This means the function MIGHT be called through unindexed code or a type-erased API. LLM should treat this as uncertain, not as confirmed dead code. Verify each hit withfind_indirect_targetsbefore deleting.
Implicit constructor calls through global/static object and member-field
initialization are detected as implicit_construct references. Known
remaining false positives: constructors called via factories, ISRs,
virtual method overrides, and weak-aliased symbols. Always verify before
deleting.
By default, SDK/vendor paths are auto-excluded via the is_project
column (which respects project config vendor_paths and
project_paths). Use project_only=False to see all results
including vendor code.
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.
limit: Maximum results (default 100).
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.
Returns:
list of dicts, each with: name, qualified_name, kind, file, line,
status ("dead" or "possibly_dead"), and reason (str —
explains why the function is classified as dead or possibly dead).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum results (default 100). | |
| 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. | |
| exclude_paths | No | Additional LIKE patterns to exclude. Merged with defaults from config. E.g. ['lib/%']. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |