Skip to content

Commit 6599eca

Browse files
authored
Merge pull request github#7138 from hvitved/ruby/forward-param-cfg
Ruby: Add missing CFG entry for `ForwardParameter`
2 parents d97b130 + 03ae588 commit 6599eca

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ module Trees {
608608
}
609609
}
610610

611+
private class ForwardParameterTree extends LeafTree, ForwardParameter { }
612+
611613
private class ForInTree extends LeafTree, ForIn { }
612614

613615
/**

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ cfg.rb:
23982398
#-----| -> yield ...
23992399

24002400
# 194| call to run_block
2401-
#-----| -> exit cfg.rb (normal)
2401+
#-----| -> forward_param
24022402

24032403
# 194| self
24042404
#-----| -> { ... }
@@ -2426,6 +2426,35 @@ cfg.rb:
24262426
# 194| x
24272427
#-----| -> call to puts
24282428

2429+
# 196| enter forward_param
2430+
#-----| -> a
2431+
2432+
# 196| forward_param
2433+
#-----| -> exit cfg.rb (normal)
2434+
2435+
# 196| exit forward_param
2436+
2437+
# 196| exit forward_param (normal)
2438+
#-----| -> exit forward_param
2439+
2440+
# 196| a
2441+
#-----| -> b
2442+
2443+
# 196| b
2444+
#-----| -> ...
2445+
2446+
# 196| ...
2447+
#-----| -> self
2448+
2449+
# 197| call to bar
2450+
#-----| -> exit forward_param (normal)
2451+
2452+
# 197| self
2453+
#-----| -> b
2454+
2455+
# 197| b
2456+
#-----| -> call to bar
2457+
24292458
desugar.rb:
24302459
# 1| enter m1
24312460
#-----| -> x

ruby/ql/test/library-tests/controlflow/graph/cfg.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def run_block
193193

194194
run_block { |x|puts x }
195195

196+
def forward_param(a, b, ...)
197+
bar(b, ...)
198+
end
199+
196200
__END__
197201

198202
Some ignored nonsense

0 commit comments

Comments
 (0)