find_dead_code
Find C/C++ functions defined but never called using libclang-based dead code detection. Identifies unused symbols that grep cannot distinguish, with support for vendor path exclusion.
Instructions
USE INSTEAD OF grep or manual code review. Find C/C++ functions that are defined but never called — libclang-powered dead code detection. grep cannot distinguish called from uncalled symbols across a codebase.
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.
Expect additional false positives from constructors called via factories, ISRs, virtual method overrides, and weak-aliased symbols. Always verify before deleting.
By default, SDK/vendor paths are auto-excluded based on the build system (mbed-os/ for Mbed OS, .pio/ for PlatformIO, zephyr/ + build/
modules/ for Zephyr), and project config exclude_paths are applied. Use
project_only=Falseto see all results including vendor code. Requires the reference index.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum results (default 100). | |
| project_only | No | When True (default), auto-excludes SDK/vendor paths (mbed-os/%, .pio/%, zephyr/%, build/%) 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 |