From 4e80b548c1ef86a3a28f9b5c54a217782beb8ee1 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Thu, 6 May 2021 16:45:27 +0100 Subject: [PATCH] Make BeginBlock CFG post-order --- .../controlflow/internal/ControlFlowGraphImpl.qll | 6 ++++-- ql/test/library-tests/controlflow/graph/Cfg.expected | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index 1e7227a24f8..c24a559e5ed 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -1108,7 +1108,8 @@ module Trees { private class SimplePostOrderStmtSequenceTree extends StmtSequenceTree, PostOrderTree { SimplePostOrderStmtSequenceTree() { this instanceof StringInterpolationComponent or - this instanceof ParenthesizedExpr + this instanceof ParenthesizedExpr or + this instanceof BeginBlock } final override predicate first(AstNode first) { first(this.getStmt(0), first) } @@ -1136,7 +1137,8 @@ module Trees { not this instanceof EndBlock and not this instanceof StringInterpolationComponent and not this instanceof Block and - not this instanceof ParenthesizedExpr + not this instanceof ParenthesizedExpr and + not this instanceof BeginBlock } final override predicate propagatesAbnormal(AstNode child) { child = this.getAStmt() } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index d3731c5e367..c04cd93be88 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -491,7 +491,7 @@ case.rb: cfg.rb: # 1| enter cfg.rb -#-----| -> BEGIN { ... } +#-----| -> self # 1| bar #-----| -> alias ... @@ -559,10 +559,10 @@ cfg.rb: #-----| -> call to puts # 15| BEGIN { ... } -#-----| -> self +#-----| -> bar # 16| call to puts -#-----| -> bar +#-----| -> BEGIN { ... } # 16| self #-----| -> "hello"