Skip to content

C and C++

Last verified end to end: 2026-10-05 (query_code schema version 1).

For exact inbound and outbound symbol edges, proof tiers, and adapter-specific caveats, see Reference Traversal.

C and C++ files share the cpp analyzer, structural adapter, and language-filter label. Use languages: ["cpp"] for source files ending in .c, .cc, .cpp, or .cxx and headers ending in .h, .hh, .hpp, .hxx, or .hin. Use where when you need a narrower boundary, for example **/*.c for C files only. Bifrost also analyzes files such as .inc or .inl when a C or C++ file includes them with a quoted #include; see language support.

#include <stdio.h>
void audit(const char *value) {}
int main(void) {
int retries = 3;
audit("c");
return retries;
}
#include <vector>
class Service {
public:
Service();
void run(int value) {}
};
Service::Service() {}
void audit(const char *value) {}
int main() {
auto retries = 5;
Service service;
service.run(retries);
audit("cpp");
return 0;
}
int statement_word_decoys() {
int switch_value = 0;
int case_value = switch_value;
int label_value = case_value;
int goto_value = label_value;
int break_value = goto_value;
int continue_value = break_value;
return continue_value;
}
int route(int selector) {
goto forward_target;
if (selector < 0) {
return 0;
}
forward_target:
for (int index = 0; index < 2; ++index) {
switch (index) {
case 0:
if (selector == index) {
continue;
}
break;
default:
goto done;
}
}
switch (selector) {
case 1:
break;
default:
selector = 2;
}
done:
return selector;
}
(where "c-family/**/*" (language cpp (call :callee "audit" :args [(capture "value")])))
{
"where": ["c-family/**/*"],
"languages": ["cpp"],
"match": {
"kind": "call",
"callee": {"name": "audit"},
"args": [{"capture": "value"}]
}
}
{
"results": [
{"result_type":"structural_match","path":"c-family/main.c","language":"cpp","kind":"call","start_line":7,"end_line":7,"text":"audit(\"c\")","captures":[{"name":"value","text":"\"c\"","start_line":7}],"enclosing_symbol":"main"},
{"result_type":"structural_match","path":"c-family/service.cpp","language":"cpp","kind":"call","start_line":17,"end_line":17,"text":"audit(\"cpp\")","captures":[{"name":"value","text":"\"cpp\"","start_line":17}],"enclosing_symbol":"main"}
],
"truncated": false
}

The same assignment query matches C’s explicit type and C++‘s auto. left and right target normalized facts instead of parsing declaration text.

(language cpp
(assignment
:left (identifier :name "retries")
:right (numeric_literal :capture "count")))
{
"languages": ["cpp"],
"match": {
"kind": "assignment",
"left": {"kind": "identifier", "name": "retries"},
"right": {"kind": "numeric_literal", "capture": "count"}
}
}
{
"results": [
{"result_type":"structural_match","path":"c-family/main.c","language":"cpp","kind":"assignment","start_line":6,"end_line":6,"text":"retries = 3","captures":[{"name":"count","text":"3","start_line":6}],"enclosing_symbol":"main"},
{"result_type":"structural_match","path":"c-family/service.cpp","language":"cpp","kind":"assignment","start_line":14,"end_line":14,"text":"retries = 5","captures":[{"name":"count","text":"5","start_line":14}],"enclosing_symbol":"main"}
],
"truncated": false
}

The path glob excludes the C fixture. Receiver, callee, and argument roles identify the member call without relying on . punctuation.

(where "c-family/**/*.cpp"
(language cpp
(call :callee "run" :receiver "service" :args [(capture "retries")])))
{
"where": ["c-family/**/*.cpp"],
"languages": ["cpp"],
"match": {
"kind": "call",
"callee": {"name": "run"},
"receiver": {"name": "service"},
"args": [{"capture": "retries"}]
}
}
{
"results": [
{"result_type":"structural_match","path":"c-family/service.cpp","language":"cpp","kind":"call","start_line":16,"end_line":16,"text":"service.run(retries)","captures":[{"name":"retries","text":"retries","start_line":16}],"enclosing_symbol":"main"}
],
"truncated": false
}
(language cpp (constructor :name "Service"))
{"languages":["cpp"],"match":{"kind":"constructor","name":"Service"}}
{
"results": [
{"result_type":"structural_match","path":"c-family/service.cpp","language":"cpp","kind":"constructor","start_line":9,"end_line":9,"text":"Service::Service() {}","enclosing_symbol":"Service.Service"}
],
"truncated": false
}
(language cpp (import :module "vector"))
{"languages":["cpp"],"match":{"kind":"import","module":{"name":"vector"}}}
{
"results": [
{"result_type":"structural_match","path":"c-family/service.cpp","language":"cpp","kind":"import","start_line":1,"end_line":2,"text":"#include <vector>…"}
],
"truncated": false
}

Statement kinds match parsed C++ constructs rather than words in identifiers or comments. The fixture includes ordinary variables named after the constructs as decoys, while the queries below select the two switches, four case/default arms, two labels, two gotos, two breaks, and one continue.

(where "cpp/**/*.cpp" (language cpp (switch)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"switch"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"switch","start_line":20,"end_line":28,"text":"switch (index) {…","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"switch","start_line":31,"end_line":36,"text":"switch (selector) {…","enclosing_symbol":"route"}
],
"truncated": false
}
(where "cpp/**/*.cpp" (language cpp (case)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"case"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"case","start_line":21,"end_line":25,"text":"case 0:…","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"case","start_line":26,"end_line":27,"text":"default:…","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"case","start_line":32,"end_line":33,"text":"case 1:…","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"case","start_line":34,"end_line":35,"text":"default:…","enclosing_symbol":"route"}
],
"truncated": false
}
(where "cpp/**/*.cpp" (language cpp (label)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"label"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"label","start_line":18,"end_line":29,"text":"forward_target:…","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"label","start_line":38,"end_line":39,"text":"done:…","enclosing_symbol":"route"}
],
"truncated": false
}
(where "cpp/**/*.cpp" (language cpp (goto)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"goto"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"goto","start_line":12,"end_line":12,"text":"goto forward_target;","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"goto","start_line":27,"end_line":27,"text":"goto done;","enclosing_symbol":"route"}
],
"truncated": false
}
(where "cpp/**/*.cpp" (language cpp (break)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"break"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"break","start_line":25,"end_line":25,"text":"break;","enclosing_symbol":"route"},
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"break","start_line":33,"end_line":33,"text":"break;","enclosing_symbol":"route"}
],
"truncated": false
}
(where "cpp/**/*.cpp" (language cpp (continue)))
{"where":["cpp/**/*.cpp"],"languages":["cpp"],"match":{"kind":"continue"}}
{
"results": [
{"result_type":"structural_match","path":"cpp/control-flow.cpp","language":"cpp","kind":"continue","start_line":23,"end_line":23,"text":"continue;","enclosing_symbol":"route"}
],
"truncated": false
}

C naturally produces only the subset of normalized facts its syntax supports. Neither C nor C++ models kwargs or decorators, and the query engine does not resolve the static type of service.

class QueryRoot {
public:
virtual void root_member() {}
};
class QueryLeaf : public QueryRoot {
public:
void leaf_member() {}
};
(supertypes :depth 2 (enclosing-decl (language cpp (class :name "QueryLeaf"))))
{"languages":["cpp"],"match":{"kind":"class","name":"QueryLeaf"},"steps":[{"op":"enclosing_decl"},{"op":"supertypes","depth":2}]}
{
"results": [
{
"end_line": 4,
"fq_name": "QueryRoot",
"kind": "class",
"language": "cpp",
"path": "cpp/hierarchy.cpp",
"provenance": [
{
"seed": {
"end_line": 9,
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "structural_match",
"start_line": 6
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 9,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 6
}
},
{
"op": "supertypes",
"result": {
"end_line": 4,
"fq_name": "QueryRoot",
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 1
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryRoot {",
"start_line": 1
}
],
"truncated": false
}
(owner (members (subtypes (enclosing-decl (language cpp (class :name "QueryRoot"))))))
{"languages":["cpp"],"match":{"kind":"class","name":"QueryRoot"},"steps":[{"op":"enclosing_decl"},{"op":"subtypes"},{"op":"members"},{"op":"owner"}]}
{
"results": [
{
"end_line": 9,
"fq_name": "QueryLeaf",
"kind": "class",
"language": "cpp",
"path": "cpp/hierarchy.cpp",
"provenance": [
{
"seed": {
"end_line": 4,
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "structural_match",
"start_line": 1
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 4,
"fq_name": "QueryRoot",
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 1
}
},
{
"op": "subtypes",
"result": {
"end_line": 9,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 6
}
},
{
"op": "members",
"result": {
"end_line": 8,
"fq_name": "QueryLeaf.leaf_member",
"kind": "function",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 8
}
},
{
"op": "owner",
"result": {
"end_line": 9,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "cpp/hierarchy.cpp",
"result_type": "declaration",
"start_line": 6
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryLeaf : public QueryRoot {",
"start_line": 6
}
],
"truncated": false
}