# C++ Support in Maguyva: Class and Call Graphs at Scale

Canonical source: https://maguyva.ai/languages/cpp

License: text under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); code samples under [MIT-0](https://opensource.org/license/mit-0); the Maguyva name, logos, brand assets and other code are not covered. Details: [maguyva.ai/license](https://maguyva.ai/license).

Maguyva parses C++ with AST, symbol, and graph support, so AI agents can follow classes, namespaces, virtual overrides, and callers in large C++ codebases.

## Support snapshot

- Tier: AST and symbol support
- Programming
- Extensions: .c, .c++, .cc, .cpp, .cxx, .h, +4 more
- Real AST parsing for syntax-aware search and structural context.
- Named symbols feed semantic lookup and cross-reference. Graph navigation is available when relationship extraction is enabled.
- This language contributes symbols and relationships to graph-aware search; supported edge types vary with its native constructs.
- AST parsing and symbol extraction are both available.

## Best fit

- Game engines, trading systems, browsers, and other large C++ codebases where one header change rebuilds half the tree.
- Class hierarchies with virtual methods, where the method that runs is defined somewhere other than where it is called.
- Agent-assisted refactoring that needs callers and overrides before a signature change.

## Agent workflows

- Find every override of a virtual method before changing the base class.
- List callers of a namespaced function or class method, such as `net::Socket::send`, across the codebase.
- Trace where a class is constructed with `new` and which members it touches next.

## Why C++ needs structure, not text search

In C++, names are not unique. `send` might be a free function, a member of three classes, and an override in a fourth. Namespaces, templates, and out-of-line definitions such as `Socket::send` in a `.cpp` file split one type across many files. Text search returns every match; it does not tell an agent which one a call reaches.

Maguyva indexes classes, members, and calls with their owners attached, so an agent can follow the real structure before it edits.

## What Maguyva extracts in C++

Maguyva covers the common C++ source and header extensions, including `.cpp`, `.cc`, `.cxx`, `.hpp`, `.hh`, and `.hxx`. Classes, structs, and functions are extracted, and an out-of-line definition such as `void Socket::send()` is attributed to its owner class and namespace. Virtual members are recorded, and template parameters are part of signatures.

Receiver typing follows parameters, local declarations, fields, range-based `for` loops, and `auto`, and it looks through `unique_ptr`, `shared_ptr`, and `optional`, so a call such as `conn->send()` can resolve to the right class. Base-class clauses feed inheritance, and `new` expressions count as instantiation.

The same export- and annotation-macro masking as C applies. About 273 standard-library names (`std::cout`, `std::endl`, `printf`, and similar) are filtered from relationships. The graph records calls, includes, inheritance, overrides, instantiation, type references, reads and writes, and `throw` edges.

## Example agent prompts

- "Which classes override `Renderer::draw`, and who calls it?" (`dependency_search`)
- "Show me `OrderBook::match` and every caller." (`find_symbol`)
- "Explain how a market-data message reaches the strategy engine." (`get_task_context`)

## Known limits

- `.h` appears in the C, C++, and Objective-C extension lists, so headers in mixed C and C++ trees are shared between those profiles.
- Object-like macro bodies are not parsed, and calls to filtered standard-library names are not graph edges. Use `text_pattern_search` for macro and `std::` usage.

## Next steps

Connect a repository with the [quickstart](/docs/quickstart), then check the support matrix on the [compatibility page](/docs/compatibility). If parts of the tree are plain C, read the [C guide](/languages/c) too.

## Engine details

- Out-of-line definitions such as `void Socket::send()` are attributed to their owner class and namespace, and virtual members are recorded.
- Receiver typing follows parameters, locals, fields, range-based `for`, and `auto`, and looks through `unique_ptr`, `shared_ptr`, and `optional`.
- Base-class clauses feed inheritance, `new` expressions count as instantiation, and about 273 standard-library names are filtered from relationships.

## Useful MCP entry points

- `find_symbol`: Use it for a qualified name such as `OrderBook::match` when you need the definition and callers.
- `dependency_search`: Use it on a base class or virtual method to find overrides and callers before a signature change.
- `get_task_context`: Use it for prompts like “explain how a market-data message reaches the strategy engine.”
