Skip to content

Commit 05aa8de

Browse files
committed
python: make LoopStmt final
1 parent aa305c2 commit 05aa8de

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,10 @@ module Ast implements AstSig<Py::Location> {
593593
}
594594

595595
/** A loop statement. */
596-
class LoopStmt extends Stmt {
597-
LoopStmt() {
596+
final class LoopStmt = LoopStmtImpl;
597+
598+
abstract private class LoopStmtImpl extends Stmt {
599+
LoopStmtImpl() {
598600
this = TPyStmt(any(Py::While w))
599601
or
600602
this = TPyStmt(any(Py::For f))
@@ -605,7 +607,7 @@ module Ast implements AstSig<Py::Location> {
605607
}
606608

607609
/** A `while` loop statement. */
608-
class WhileStmt extends LoopStmt {
610+
class WhileStmt extends LoopStmtImpl {
609611
private Py::While whileStmt;
610612

611613
WhileStmt() { this = TPyStmt(whileStmt) }
@@ -630,21 +632,21 @@ module Ast implements AstSig<Py::Location> {
630632
/**
631633
* A `do-while` loop statement. Python has no do-while construct.
632634
*/
633-
class DoStmt extends LoopStmt {
635+
class DoStmt extends LoopStmtImpl {
634636
DoStmt() { none() }
635637

636638
Expr getCondition() { none() }
637639
}
638640

639641
/** An `until` loop. Python has no `until` loop. */
640-
class UntilStmt extends LoopStmt {
642+
class UntilStmt extends LoopStmtImpl {
641643
UntilStmt() { none() }
642644

643645
Expr getCondition() { none() }
644646
}
645647

646648
/** A C-style `for` loop. Python has no C-style for loop. */
647-
class ForStmt extends LoopStmt {
649+
class ForStmt extends LoopStmtImpl {
648650
ForStmt() { none() }
649651

650652
AstNode getInit(int index) { none() }
@@ -655,7 +657,7 @@ module Ast implements AstSig<Py::Location> {
655657
}
656658

657659
/** A for-each loop (`for x in iterable:`). */
658-
class ForeachStmt extends LoopStmt {
660+
class ForeachStmt extends LoopStmtImpl {
659661
private Py::For forStmt;
660662

661663
ForeachStmt() { this = TPyStmt(forStmt) }

0 commit comments

Comments
 (0)