Skip to content

Commit c91b6c9

Browse files
yoffCopilot
andcommitted
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>
1 parent 091479c commit c91b6c9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* wrapped.
1010
* - Intermediate nodes for multi-operand boolean expressions.
1111
*/
12-
1312
overlay[local?]
1413
module;
1514

@@ -635,11 +634,11 @@ module Ast implements AstSig<Py::Location> {
635634
class ForStmt extends LoopStmt {
636635
ForStmt() { none() }
637636

638-
Expr getInit(int index) { none() }
637+
AstNode getInit(int index) { none() }
639638

640639
Expr getCondition() { none() }
641640

642-
Expr getUpdate(int index) { none() }
641+
AstNode getUpdate(int index) { none() }
643642
}
644643

645644
/** A for-each loop (`for x in iterable:`). */
@@ -941,7 +940,7 @@ module Ast implements AstSig<Py::Location> {
941940

942941
Case() { this = TPyStmt(caseStmt) }
943942

944-
AstNode getAPattern() { result.asPattern() = caseStmt.getPattern() }
943+
AstNode getPattern(int index) { index = 0 and result.asPattern() = caseStmt.getPattern() }
945944

946945
Expr getGuard() { result.asExpr() = caseStmt.getGuard().(Py::Guard).getTest() }
947946

@@ -951,7 +950,7 @@ module Ast implements AstSig<Py::Location> {
951950
predicate isWildcard() { caseStmt.getPattern() instanceof Py::MatchWildcardPattern }
952951

953952
override AstNode getChild(int index) {
954-
index = 0 and result = this.getAPattern()
953+
index = 0 and result = this.getPattern(0)
955954
or
956955
index = 1 and result = this.getGuard()
957956
or

0 commit comments

Comments
 (0)