diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index ca71e213e327..7e5072637c30 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -175,7 +175,9 @@ module Ast implements AstSig { final private class FinalForStmt = CS::ForStmt; class ForStmt extends FinalForStmt { - Expr getInit(int index) { result = this.getInitializer(index) } + AstNode getInit(int index) { result = super.getInitializer(index) } + + AstNode getUpdate(int index) { result = super.getUpdate(index) } } final private class FinalForeachStmt = CS::ForeachStmt; diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index 27f0102b3cfb..3407a43403e8 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -84,7 +84,13 @@ private module Ast implements AstSig { class DoStmt = J::DoStmt; - class ForStmt = J::ForStmt; + final private class FinalForStmt = J::ForStmt; + + class ForStmt extends FinalForStmt { + AstNode getInit(int index) { result = super.getInit(index) } + + AstNode getUpdate(int index) { result = super.getUpdate(index) } + } final private class FinalEnhancedForStmt = J::EnhancedForStmt; diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 7a6b6318ed11..efb6be55273c 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -118,14 +118,14 @@ signature module AstSig { /** A traditional C-style `for` loop. */ class ForStmt extends LoopStmt { - /** Gets the initializer expression of the loop at the specified (zero-based) position, if any. */ - Expr getInit(int index); + /** Gets the initializer of the loop at the specified (zero-based) position, if any. */ + AstNode getInit(int index); /** Gets the boolean condition of this `for` loop. */ Expr getCondition(); - /** Gets the update expression of this loop at the specified (zero-based) position, if any. */ - Expr getUpdate(int index); + /** Gets the update of this loop at the specified (zero-based) position, if any. */ + AstNode getUpdate(int index); } /** A for-loop that iterates over the elements of a collection. */