From 53f30a0796ae179132d3a3601c5409eee4dce60d Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Wed, 2 Sep 2026 10:53:35 +0200 Subject: [PATCH] CFG: Rename ForeachStmt to ForEachStmt. --- .../code/csharp/controlflow/internal/ControlFlowGraph.qll | 2 +- java/ql/lib/semmle/code/java/ControlFlowGraph.qll | 2 +- .../semmle/python/controlflow/internal/AstNodeImpl.qll | 6 +++--- ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll | 6 +++--- .../controlflow/codeql/controlflow/ControlFlowGraph.qll | 8 ++++---- .../ql/lib/codeql/unified/internal/ControlFlowGraph.qll | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) 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 14bbb0251728..b30646466a57 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -190,7 +190,7 @@ module Ast implements AstSig { final private class FinalForeachStmt = CS::ForeachStmt; - class ForeachStmt extends FinalForeachStmt { + class ForEachStmt extends FinalForeachStmt { Expr getVariable() { result = this.getVariableDeclExpr() or result = this.getVariableDeclTuple() } diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index c4f0c44b3813..1281afc52728 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -100,7 +100,7 @@ private module Ast implements AstSig { final private class FinalEnhancedForStmt = J::EnhancedForStmt; - class ForeachStmt extends FinalEnhancedForStmt { + class ForEachStmt extends FinalEnhancedForStmt { Expr getVariable() { result = super.getVariable() } Expr getCollection() { result = super.getExpr() } diff --git a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll index 78218f489215..1cc3082d90f7 100644 --- a/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll +++ b/python/ql/lib/semmle/python/controlflow/internal/AstNodeImpl.qll @@ -657,10 +657,10 @@ module Ast implements AstSig { } /** A for-each loop (`for x in iterable:`). */ - class ForeachStmt extends LoopStmtImpl { + class ForEachStmt extends LoopStmtImpl { private Py::For forStmt; - ForeachStmt() { this = TPyStmt(forStmt) } + ForEachStmt() { this = TPyStmt(forStmt) } /** Gets the loop variable. */ Expr getVariable() { result.asExpr() = forStmt.getTarget() } @@ -898,7 +898,7 @@ module Ast implements AstSig { AstNode getLoopElse(LoopStmt loop) { result = loop.(WhileStmt).getElse() or - result = loop.(ForeachStmt).getElse() + result = loop.(ForEachStmt).getElse() } /** An exception handler (`except` or `except*`). */ diff --git a/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll b/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll index 4ad4c3d6a41b..419f840290c4 100644 --- a/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll +++ b/ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll @@ -295,9 +295,9 @@ private module Ast implements AstSig { AstNode getUpdate(int index) { none() } } - // `ForExpr` would be a match for `ForeachStmt`, but it is desugared. - class ForeachStmt extends LoopStmt { - ForeachStmt() { none() } + // `ForExpr` would be a match for `ForEachStmt`, but it is desugared. + class ForEachStmt extends LoopStmt { + ForEachStmt() { none() } Expr getVariable() { none() } diff --git a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll index 21bdcf5b8335..c1a121f810df 100644 --- a/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll +++ b/shared/controlflow/codeql/controlflow/ControlFlowGraph.qll @@ -147,7 +147,7 @@ signature module AstSig { } /** A for-loop that iterates over the elements of a collection. */ - class ForeachStmt extends LoopStmt { + class ForEachStmt extends LoopStmt { /** Gets the variable declaration of this `foreach` loop. */ Expr getVariable(); @@ -650,7 +650,7 @@ module Make0 Ast> { any(Case case).getGuard() = n ) or - any(ForeachStmt foreachstmt).getCollection() = n and kind.isEmptiness() + any(ForEachStmt foreachstmt).getCollection() = n and kind.isEmptiness() or kind.isMatching() and ( @@ -1656,7 +1656,7 @@ module Make0 Ast> { n2.isAfter(loopstmt) ) or - exists(ForeachStmt foreachstmt | + exists(ForEachStmt foreachstmt | n1.isBefore(foreachstmt) and n2.isBefore(foreachstmt.getCollection()) or @@ -2401,7 +2401,7 @@ module Make0 Ast> { // allow for loop headers in foreach loops (they're checking emptiness on the iterator, not the collection) not ( t instanceof DirectSuccessor and - node.isAdditional(any(ForeachStmt foreach), loopHeaderTag()) + node.isAdditional(any(ForEachStmt foreach), loopHeaderTag()) ) and // allow for functions with multiple bodies not exists(Callable c | diff --git a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll index ee27d4a28bc8..15db0eb3836e 100644 --- a/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll +++ b/unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll @@ -123,7 +123,7 @@ private module Ast implements AstSig { AstNode getUpdate(int index) { none() } } - class ForeachStmt extends LoopStmt instanceof U::ForEachStmt { + class ForEachStmt extends LoopStmt instanceof U::ForEachStmt { override Stmt getBody() { result = U::ForEachStmt.super.getBody() } // TODO support foreach guard