Phase 1 — Complete. The shared CFG library is now instantiated and wired into Go:

Created ControlFlowGraphShared.qll — contains the full GoCfg module with:

Ast module implementing AstSig<Location> — maps Go's AST types to the shared interface, with empty types for constructs Go doesn't have (while/do/try/catch/throw/ternary/null-coalescing)
Input module implementing InputSig1 + InputSig2 — labels, conditional contexts, custom step() predicates for if-with-init, for/range loops, expression/type switches, case clauses, select, defer, and go statements; abrupt completions for panics, fallthrough, and goto
Make0/Make1/Make2 wiring and import Public
Modified ControlFlowGraph.qll — added import of the shared library and re-exports it as module SharedCfg = GoCfg, making shared types accessible as SharedCfg::ControlFlowNode, SharedCfg::ControlFlow::EntryNode, SharedCfg::BasicBlock, etc.

No breakage — all 90 src queries and library files compile cleanly.
This commit is contained in:
Owen Mansel-Chan
2026-03-30 13:27:52 +01:00
parent d4ce252e7b
commit 0e2125b385

View File

@@ -6,6 +6,7 @@ module;
import go
private import ControlFlowGraphImpl
private import ControlFlowGraphShared
/** Provides helper predicates for mapping btween CFG nodes and the AST. */
module ControlFlow {
@@ -359,3 +360,13 @@ module ControlFlow {
class ControlFlowNode = ControlFlow::Node;
class Write = ControlFlow::WriteNode;
/**
* Provides the shared CFG library types for Go.
*
* These types are generated by the shared `codeql.controlflow.ControlFlowGraph`
* library and coexist with the existing Go CFG types during the transition.
* Use `SharedCfg::ControlFlowNode` to access the shared library's node type,
* `SharedCfg::ControlFlow::EntryNode` for entry nodes, etc.
*/
module SharedCfg = GoCfg;