Skip to main content
Glama

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 1 ref_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 with find_indirect_targets before 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

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum results (default 100).
project_onlyNoWhen 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_rootNoProject root. Auto-detected if omitted.
exclude_pathsNoAdditional LIKE patterns to exclude. Merged with defaults from config. E.g. ['lib/%'].

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries full burden. It discloses read-only nature, no side effects, dependency on reference index, auto-exclusion of vendor paths, and explains the logic behind 'dead' vs 'possibly_dead' statuses. Known false positives are listed, and the return format is fully described.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is somewhat long but well-structured with clear sections: purpose, categories, caveats, parameter details, return info. It is front-loaded with the main purpose. Minor redundancy exists (e.g., repetition of default values), but overall it earns its length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the output schema is provided (list of dicts) and the description thoroughly explains each field and status, there is no missing information. Parameter details are complete, caveats are included, and the tool's constraints (index requirement, vendor exclusion) are stated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds value by explaining the purpose of each parameter beyond the schema: project_root auto-detection, limit default, exclude_paths as additional patterns, and project_only filtering logic. This justifies a 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Find C/C++ functions that are defined but never called' and distinguishes between 'dead' and 'possibly_dead'. This verb+resource combination is unique among sibling tools, which focus on callers, references, or code search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly contrasts with text-based search, states that text search cannot determine reachability, and advises using this tool for dead code detection. It also provides guidance on when not to trust results (e.g., constructors, ISRs) and recommends verification with find_indirect_targets.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/turbyho/fw-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server