Docs / languages / cpp · Edit on GitHub

C++

Tier 1 plugin for C++ source and headers. Extracts class inheritance, template instantiation edges, and call resolution.

Implementation

Plugin cratecrates/rgctl-lang-cpp (CppPlugin)
Grammartree-sitter-cpp
Extensions.cpp, .cc, .cxx, .hpp, .hh, .hxx
Discoverrgctl discover . -l cpp -e build,cmake-build-debug,.rgctl --with-cfg
CFG / taintEnabled

Tree-sitter node kinds: function_definition, class_specifier, struct_specifier, enum_specifier, preproc_include, using_declaration.

What is extracted

Nodes

  • Function — free functions and methods
  • Class, Struct, Enum
  • Import#include and using declarations

Edges

EdgeMeaning
CALLSFunction and method calls
EXTENDSClass inheritance (: public Base)
INSTANTIATESTemplate and constructor instantiation

Verification

Fixturergctl-tests/ecommerce-cpp
Example corpusexample/llvm-project/clang (-l cpp)
Smoke scriptrgctl-tests/gql-verification-smoke/verify-extraction-gql-cpp.sh

GQL verification queries

Fixture probes

ProbeGQL
Inheritance (EXTENDS)MATCH (a)-[:EXTENDS]->(b) RETURN a,b LIMIT 10000
Instantiation (INSTANTIATES)MATCH (a)-[:INSTANTIATES]->(b) RETURN a,b LIMIT 10000
Call resolution (CALLS)MATCH (a)-[:CALLS]->(b) RETURN a,b LIMIT 10000

Example smoke (example/llvm-project/clang)

ProbeGQL
EXTENDS (scale)MATCH (a)-[:EXTENDS]->(b) RETURN a,b LIMIT 10000
INSTANTIATES (scale)MATCH (a)-[:INSTANTIATES]->(b) RETURN a,b LIMIT 10000
CALLS (scale)MATCH (a)-[:CALLS]->(b) RETURN a,b LIMIT 10000

Related

  • Languages index
  • C
  • Openspec: cpp-inheritance-edges, cpp-instantiation, cpp-call-resolution