Skip to main content

Module inverted

Module inverted 

Source
Expand description

Whole-workspace inverted edge builder for C++.

Walks each file once and resolves every reference to the callee fqn it names, via the shared build_edges driver in brokk-bifrost-analysis. C++ node fqns are dotted: a namespace + class + member reads example.Service.run, a free function example.freeHelper, and a class example.Service. References resolve through the forward scanner’s visibility primitives (VisibilityIndex::resolve_type / resolve_named, which honor the include closure and namespaces) plus a LocalInferenceEngine (typed by CodeUnit, like the forward scan) seeded with every local’s and parameter’s declared type so a method call’s receiver can be typed:

  • a type reference (Foo x, new Foo(), a base class) resolves to the class;
  • recv.m(..) / recv->m(..) (field_expression under a call) types recv and gives Owner.m;
  • X::m(..) (qualified_identifier) resolves X and gives Owner.m;
  • a bare m(..) is a free function (Namespace.m); this->m(..) and other unqualified member calls attribute to the enclosing class;
  • a chained receiver (p->get()->m()) follows the uniquely resolved persisted callable return type before recording Owner.m.

The enclosing class is taken from a per-file class-range index (the analyzer’s own fqns), so this->/unqualified calls attribute to the right class without re-deriving the namespace. Ambiguous receiver or return identities fail closed.

Functions§

scan_file
The C++ half of one file’s inverted pass: seed the scan context from the already-parsed tree and walk it, recording every caller -> callee edge the file names.