From c91b6c9eaf3bc4a39a4020dbdd34377bc9751566 Mon Sep 17 00:00:00 2001 From: yoff Date: Tue, 26 May 2026 16:47:30 +0000 Subject: [PATCH] Python: adapt AstNodeImpl to upstream shared-CFG signature changes - ForStmt.getInit(int)/getUpdate(int) now return AstNode (was Expr) - Case.getAPattern() renamed to getPattern(int index) Both are stubs in Python (no C-style for, single match pattern). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../semmle/python/controlflow/internal/AstNodeImpl.qll | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll index e41d82a9ad0..9c6e9322c28 100644 --- a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll +++ b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll @@ -9,7 +9,6 @@ * wrapped. * - Intermediate nodes for multi-operand boolean expressions. */ - overlay[local?] module; @@ -635,11 +634,11 @@ module Ast implements AstSig { class ForStmt extends LoopStmt { ForStmt() { none() } - Expr getInit(int index) { none() } + AstNode getInit(int index) { none() } Expr getCondition() { none() } - Expr getUpdate(int index) { none() } + AstNode getUpdate(int index) { none() } } /** A for-each loop (`for x in iterable:`). */ @@ -941,7 +940,7 @@ module Ast implements AstSig { Case() { this = TPyStmt(caseStmt) } - AstNode getAPattern() { result.asPattern() = caseStmt.getPattern() } + AstNode getPattern(int index) { index = 0 and result.asPattern() = caseStmt.getPattern() } Expr getGuard() { result.asExpr() = caseStmt.getGuard().(Py::Guard).getTest() } @@ -951,7 +950,7 @@ module Ast implements AstSig { predicate isWildcard() { caseStmt.getPattern() instanceof Py::MatchWildcardPattern } override AstNode getChild(int index) { - index = 0 and result = this.getAPattern() + index = 0 and result = this.getPattern(0) or index = 1 and result = this.getGuard() or