From c47135a40b2c0a2e6d9c11f826655de27e8f61d3 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 8 Jun 2026 13:40:33 +0200 Subject: [PATCH] Cfg: Add consistency check for relevant child indices. --- .../codeql/controlflow/ControlFlowGraph.qll | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index fff877b9fcd..e917d772886 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -2090,6 +2090,12 @@ module Make0 Ast> { module Consistency { /** Holds if the consistency query `query` has `results` results. */ query predicate consistencyOverview(string query, int results) { + query = "siblingsWithSameIndexInDefaultCfg" and + results = + strictcount(AstNode parent, AstNode child1, AstNode child2, int i | + siblingsWithSameIndexInDefaultCfg(parent, child1, child2, i) + ) + or query = "deadEnd" and results = strictcount(ControlFlowNode node | deadEnd(node)) or query = "nonUniqueEnclosingCallable" and @@ -2135,6 +2141,20 @@ module Make0 Ast> { results = strictcount(ControlFlowNode node, SuccessorType t | selfLoop(node, t)) } + /** + * Holds if `parent` uses default left-to-right control flow and has + * two different children `child1` and `child2` at the same index + * `i`. + */ + query predicate siblingsWithSameIndexInDefaultCfg( + AstNode parent, AstNode child1, AstNode child2, int i + ) { + defaultCfg(parent) and + getChild(parent, i) = child1 and + getChild(parent, i) = child2 and + child1 != child2 + } + /** * Holds if `node` is lacking a successor. *