From eafec4331b3e232cdcab315956a01961aec5471b Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 16 Dec 2020 10:47:51 +0100 Subject: [PATCH] CFG: add nodes for block arguments --- .../controlflow/internal/ControlFlowGraphImpl.qll | 3 ++- ql/test/library-tests/controlflow/graph/Cfg.expected | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index a361f94fe54..d0f0d255251 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -313,13 +313,14 @@ module Trees { } private class CallTree extends StandardPostOrderTree, Call { - // this.getBlock() is not included as it uses a different scope final override AstNode getChildNode(int i) { result = this.getReceiver() and i = 0 or result = this.getMethod() and i = 1 or result = this.getArguments() and i = 2 + or + result = this.getBlock() and i = 3 } } diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index a3988ce2340..a5bd861ba6b 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -647,6 +647,9 @@ cfg.rb: #-----| -> times # 25| times +#-----| -> Block + +# 25| Block #-----| -> Call # 25| x @@ -680,6 +683,9 @@ cfg.rb: #-----| -> new # 29| new +#-----| -> Block + +# 29| Block #-----| -> Call # 29| BlockParameter @@ -1985,6 +1991,9 @@ cfg.rb: #-----| -> exit top-level (normal) # 189| run_block +#-----| -> Block + +# 189| Block #-----| -> Call # 189| x @@ -2627,6 +2636,9 @@ loops.rb: #-----| -> Array # 25| each +#-----| -> DoBlock + +# 25| DoBlock #-----| -> Call # 25| x