From 31b8d33a7cf6b8edcb7bb3b2433989f55d2bd280 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Mon, 7 Dec 2020 17:18:18 +0100 Subject: [PATCH] CFG: Mark `redo` edges out of `for` loops --- .../codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll | 4 ++-- ql/test/library-tests/controlflow/graph/Cfg.expected | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index d0df3768d98..d936a68b361 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -1327,9 +1327,9 @@ module Trees { first(this.getConditionNode(), succ) and c.continuesLoop() or - last(this.getBodyNode(), pred, any(RedoCompletion rc)) and + last(this.getBodyNode(), pred, c) and first(this.getBodyNode(), succ) and - c instanceof SimpleCompletion + c instanceof RedoCompletion } } } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index 2d1ad8f449c..e4b7b36ccdb 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -1685,7 +1685,7 @@ edges | cfg.rb:179:6:179:11 | Binary | cfg.rb:179:18:179:21 | Redo | semmle.label | true | | cfg.rb:179:6:179:11 | Binary | cfg.rb:180:8:180:8 | x | semmle.label | false | | cfg.rb:179:11:179:11 | 5 | cfg.rb:179:6:179:11 | Binary | semmle.label | successor | -| cfg.rb:179:18:179:21 | Redo | cfg.rb:178:3:178:3 | x | semmle.label | successor | +| cfg.rb:179:18:179:21 | Redo | cfg.rb:178:3:178:3 | x | semmle.label | redo | | cfg.rb:180:3:180:6 | puts | cfg.rb:180:3:180:8 | MethodCall | semmle.label | successor | | cfg.rb:180:3:180:8 | MethodCall | cfg.rb:177:7:177:7 | x | semmle.label | successor | | cfg.rb:180:8:180:8 | x | cfg.rb:180:3:180:6 | puts | semmle.label | successor | @@ -1875,7 +1875,7 @@ edges | loops.rb:16:11:16:16 | Binary | loops.rb:17:7:17:10 | Redo | semmle.label | true | | loops.rb:16:11:16:16 | Binary | loops.rb:19:10:19:15 | String | semmle.label | false | | loops.rb:16:15:16:16 | 10 | loops.rb:16:11:16:16 | Binary | semmle.label | successor | -| loops.rb:17:7:17:10 | Redo | loops.rb:10:10:10:10 | x | semmle.label | successor | +| loops.rb:17:7:17:10 | Redo | loops.rb:10:10:10:10 | x | semmle.label | redo | | loops.rb:19:5:19:8 | puts | loops.rb:19:5:19:15 | MethodCall | semmle.label | successor | | loops.rb:19:5:19:15 | MethodCall | loops.rb:9:9:9:9 | x | semmle.label | successor | | loops.rb:19:10:19:15 | String | loops.rb:19:5:19:8 | puts | semmle.label | successor |