File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
lib/codeql/ruby/controlflow/internal
test/library-tests/controlflow/graph Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -932,7 +932,13 @@ module Trees {
932
932
class StmtSequenceTree extends PostOrderTree , StmtSequence {
933
933
override predicate propagatesAbnormal ( AstNode child ) { child = this .getAStmt ( ) }
934
934
935
- override predicate first ( AstNode first ) { first ( this .getStmt ( 0 ) , first ) }
935
+ override predicate first ( AstNode first ) {
936
+ // If this sequence contains any statements, go to the first one.
937
+ first ( this .getStmt ( 0 ) , first )
938
+ or
939
+ // Otherwise, treat this node as a leaf node.
940
+ not exists ( this .getStmt ( 0 ) ) and first = this
941
+ }
936
942
937
943
/** Gets the `i`th child in the body of this body statement. */
938
944
AstNode getBodyChild ( int i , boolean rescuable ) {
Original file line number Diff line number Diff line change @@ -3675,6 +3675,7 @@ ifs.rb:
3675
3675
#-----| -> self
3676
3676
3677
3677
# 47| b
3678
+ #-----| false -> else ...
3678
3679
#-----| true -> self
3679
3680
3680
3681
# 47| then ...
@@ -3689,6 +3690,9 @@ ifs.rb:
3689
3690
# 48| "true"
3690
3691
#-----| -> call to puts
3691
3692
3693
+ # 49| else ...
3694
+ #-----| -> if ...
3695
+
3692
3696
# 51| call to puts
3693
3697
#-----| -> exit empty_else (normal)
3694
3698
@@ -4006,6 +4010,7 @@ loops.rb:
4006
4010
#-----| -> exit m4 (normal)
4007
4011
4008
4012
# 31| ... < ...
4013
+ #-----| true -> do ...
4009
4014
#-----| false -> while ...
4010
4015
4011
4016
# 31| x
@@ -4014,6 +4019,9 @@ loops.rb:
4014
4019
# 31| y
4015
4020
#-----| -> ... < ...
4016
4021
4022
+ # 31| do ...
4023
+ #-----| -> x
4024
+
4017
4025
raise.rb:
4018
4026
# 1| enter raise.rb
4019
4027
#-----| -> ExceptionA
@@ -5116,9 +5124,20 @@ raise.rb:
5116
5124
# 147| [ensure: raise] 3
5117
5125
#-----| -> [ensure: raise] return
5118
5126
5127
+ # 150| enter m13
5128
+ #-----| -> ensure ...
5129
+
5119
5130
# 150| m13
5120
5131
#-----| -> m14
5121
5132
5133
+ # 150| exit m13
5134
+
5135
+ # 150| exit m13 (normal)
5136
+ #-----| -> exit m13
5137
+
5138
+ # 151| ensure ...
5139
+ #-----| -> exit m13 (normal)
5140
+
5122
5141
# 154| enter m14
5123
5142
#-----| -> element
5124
5143
You can’t perform that action at this time.
0 commit comments