diff --git a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll index e736460be63..bd8011c54ca 100644 --- a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll +++ b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll @@ -151,13 +151,13 @@ module GoCfg { } class ForStmt extends LoopStmt { - ForStmt() { none() } + ForStmt() { this instanceof Go::ForStmt } - Expr getInit(int index) { none() } + AstNode getInit(int index) { index = 0 and result = this.(Go::ForStmt).getInit() } - Expr getCondition() { none() } + Expr getCondition() { result = this.(Go::ForStmt).getCond() } - Expr getUpdate(int index) { none() } + AstNode getUpdate(int index) { index = 0 and result = this.(Go::ForStmt).getPost() } } class ForeachStmt extends LoopStmt { @@ -727,7 +727,6 @@ module GoCfg { predicate step(PreControlFlowNode n1, PreControlFlowNode n2) { ifWithInit(n1, n2) or - forLoop(n1, n2) or rangeLoop(n1, n2) or switchStmt(n1, n2) or selectStmt(n1, n2) or @@ -1192,49 +1191,6 @@ module GoCfg { ) } - private predicate forLoop(PreControlFlowNode n1, PreControlFlowNode n2) { - exists(Go::ForStmt s | - exists(PreControlFlowNode cond | - ( - cond.isBefore(s.getCond()) - or - not exists(s.getCond()) and cond.isBefore(s.getBody()) - ) - | - n1.isBefore(s) and - ( - n2.isBefore(s.getInit()) - or - not exists(s.getInit()) and n2 = cond - ) - or - n1.isAfter(s.getInit()) and n2 = cond - or - n1.isAfterTrue(s.getCond()) and n2.isBefore(s.getBody()) - or - n1.isAfterFalse(s.getCond()) and n2.isAfter(s) - or - not exists(s.getCond()) and - n1.isAfter(s.getBody()) and - ( - n2.isBefore(s.getPost()) - or - not exists(s.getPost()) and n2.isBefore(s.getBody()) - ) - or - exists(s.getCond()) and - n1.isAfter(s.getBody()) and - ( - n2.isBefore(s.getPost()) - or - not exists(s.getPost()) and n2 = cond - ) - or - n1.isAfter(s.getPost()) and n2 = cond - ) - ) - } - private predicate rangeLoop(PreControlFlowNode n1, PreControlFlowNode n2) { exists(Go::RangeStmt s | n1.isBefore(s) and n2.isBefore(s.getDomain())