Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eafec43

Browse files
committed
CFG: add nodes for block arguments
1 parent d016e3c commit eafec43

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,14 @@ module Trees {
313313
}
314314

315315
private class CallTree extends StandardPostOrderTree, Call {
316-
// this.getBlock() is not included as it uses a different scope
317316
final override AstNode getChildNode(int i) {
318317
result = this.getReceiver() and i = 0
319318
or
320319
result = this.getMethod() and i = 1
321320
or
322321
result = this.getArguments() and i = 2
322+
or
323+
result = this.getBlock() and i = 3
323324
}
324325
}
325326

ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ cfg.rb:
647647
#-----| -> times
648648

649649
# 25| times
650+
#-----| -> Block
651+
652+
# 25| Block
650653
#-----| -> Call
651654

652655
# 25| x
@@ -680,6 +683,9 @@ cfg.rb:
680683
#-----| -> new
681684

682685
# 29| new
686+
#-----| -> Block
687+
688+
# 29| Block
683689
#-----| -> Call
684690

685691
# 29| BlockParameter
@@ -1985,6 +1991,9 @@ cfg.rb:
19851991
#-----| -> exit top-level (normal)
19861992

19871993
# 189| run_block
1994+
#-----| -> Block
1995+
1996+
# 189| Block
19881997
#-----| -> Call
19891998

19901999
# 189| x
@@ -2627,6 +2636,9 @@ loops.rb:
26272636
#-----| -> Array
26282637

26292638
# 25| each
2639+
#-----| -> DoBlock
2640+
2641+
# 25| DoBlock
26302642
#-----| -> Call
26312643

26322644
# 25| x

0 commit comments

Comments
 (0)