C++ Code Analysis

Structural analysis of C++ applications, game engines, embedded systems, and high-performance computing code

What Axiom Refract Analyzes in C++

Include Graph Resolution

Resolves #include directives for both system and local headers, mapping the include graph across the entire project. Handles include paths, header guards, and pragma once deduplication.

Class Hierarchy and Template Analysis

Maps class inheritance hierarchies including virtual inheritance, multiple inheritance, and CRTP patterns. Analyzes template instantiations and specializations to identify template-driven coupling.

Namespace and Linkage Analysis

Resolves namespace hierarchies, using declarations, and linkage specifications. Identifies symbol visibility across translation units and detects ODR (One Definition Rule) violation risks.

Build System Dependency Extraction

Parses CMakeLists.txt, Makefile, and Meson build definitions to map build target dependencies alongside source-level include dependencies.

How It Works

C++ is parsed using a hand-hardened Tree-sitter grammar supporting C++11 through C++23 syntax, including concepts, modules (partial), coroutines, ranges, std::format, and deducing this. The parser handles preprocessor directives including conditional compilation (#ifdef, #if), macro definitions, and include path resolution. Header-only libraries are detected and their transitive include impact is calculated.

Common Findings in C++ Codebases

Header Dependency Explosion

C++ projects frequently develop headers that transitively include hundreds of other headers. Axiom identifies headers with high transitive include counts and recommends forward declaration or pimpl patterns.

Compilation Unit Coupling

C++ translation units can become tightly coupled through shared headers with implementation details. Axiom identifies headers that should be split into interface and implementation components.

Template Instantiation Blast Radius

Template changes affect every translation unit that instantiates them. Axiom maps template usage across the codebase and calculates the compilation blast radius of template modifications.

Virtual Inheritance Diamond

Multiple inheritance with diamond patterns in C++ creates fragile class hierarchies. Axiom identifies diamond inheritance structures and their virtual/non-virtual base class resolution.

Polyglot Support

C++ is one of 145+ languages Axiom Refract supports through Tree-sitter AST parsing. C++ analysis covers CMakeLists.txt, Makefile, Meson build files, vcxproj, premake5.lua, Conan profiles, vcpkg manifests, and compile_commands.json. Build system integration provides additional dependency context beyond source-level include analysis. Your entire codebase is analyzed in a single scan — regardless of how many languages it contains.

Analyze your C++ codebase.