Skip to content

Commit e1e13b5

Browse files
committed
Fix CFG
1 parent d91b189 commit e1e13b5

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ module Trees {
371371
CallTree() {
372372
// Logical operations are handled separately
373373
not this instanceof UnaryLogicalOperation and
374-
not this instanceof BinaryLogicalOperation
374+
not this instanceof BinaryLogicalOperation and
375+
// Calls with the `&.` operator are desugared
376+
not this.(MethodCall).isSafeNavigation()
375377
}
376378

377379
override ControlFlowTree getChildElement(int i) { result = this.getArgument(i) }

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,7 +3593,6 @@ cfg.rb:
35933593
#-----| -> do ... end
35943594

35953595
# 202| call to times
3596-
#-----| -> self
35973596
#-----| -> __synth__0__1
35983597

35993598
# 202| do ... end
@@ -3636,7 +3635,6 @@ cfg.rb:
36363635

36373636
# 205| call to foo
36383637
#-----| -> ... = ...
3639-
#-----| -> 1
36403638

36413639
# 205| nil
36423640
#-----| -> if ...
@@ -3647,9 +3645,6 @@ cfg.rb:
36473645
# 205| ...
36483646
#-----| -> exit cfg.rb (normal)
36493647

3650-
# 205| call to bar
3651-
#-----| -> exit cfg.rb (normal)
3652-
36533648
# 205| call to bar
36543649
#-----| -> if ...
36553650

@@ -3679,7 +3674,6 @@ cfg.rb:
36793674

36803675
# 205| { ... }
36813676
#-----| -> call to bar
3682-
#-----| -> call to bar
36833677

36843678
# 205| x
36853679
#-----| -> x

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,6 @@ positionalArguments
205205
| cfg.rb:200:18:200:30 | call to puts | cfg.rb:200:30:200:30 | a |
206206
| cfg.rb:202:19:202:31 | call to puts | cfg.rb:202:31:202:31 | c |
207207
| cfg.rb:205:1:205:23 | call to bar | cfg.rb:205:10:205:10 | 1 |
208-
| cfg.rb:205:1:205:23 | call to bar | cfg.rb:205:10:205:10 | 1 |
209-
| cfg.rb:205:1:205:23 | call to bar | cfg.rb:205:12:205:12 | 2 |
210208
| cfg.rb:205:1:205:23 | call to bar | cfg.rb:205:12:205:12 | 2 |
211209
| cfg.rb:205:4:205:5 | call to == | cfg.rb:205:1:205:3 | __synth__0__1 |
212210
| desugar.rb:2:5:2:6 | ... + ... | desugar.rb:2:8:2:8 | 1 |

0 commit comments

Comments
 (0)