Skip to content

Commit 9ca8617

Browse files
committed
Limit Go explicit CFG child ranking to its consumers
Only function bodies and nodes with epilogue tags need child ranks for explicit sequencing. Restrict the ranking domain instead of ranking children across the entire AST. Cold ReflectedXss profiles reduce ranked-child rows from 2.09M to 279K on CockroachDB and from 2.69M to 571K on AWS, with unchanged explicit steps and full BQRS results. All 220 Go control-flow/data-flow tests including consistency queries pass. No end-to-end speedup claimed.
1 parent e2ed087 commit 9ca8617

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,15 @@ module CfgImpl {
11121112

11131113
/**
11141114
* Gets the non-skipped child of `parent` at rank `rnk` (1-based).
1115-
* This mimics the shared library's getRankedChild but for use in explicit steps.
1115+
* This mimics the shared library's getRankedChild for explicit sequencing of
1116+
* function bodies and nodes with epilogues.
11161117
*/
11171118
private Ast::AstNode getRankedChild(Ast::AstNode parent, int rnk) {
1119+
(
1120+
parent = any(Go::FuncDef fd).getBody()
1121+
or
1122+
exists(getEpilogueTag(parent, _))
1123+
) and
11181124
result = rank[rnk](Ast::AstNode c, int ix | c = Ast::getChild(parent, ix) | c order by ix)
11191125
}
11201126

0 commit comments

Comments
 (0)