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 {
932932 class StmtSequenceTree extends PostOrderTree , StmtSequence {
933933 override predicate propagatesAbnormal ( AstNode child ) { child = this .getAStmt ( ) }
934934
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+ }
936942
937943 /** Gets the `i`th child in the body of this body statement. */
938944 AstNode getBodyChild ( int i , boolean rescuable ) {
Original file line number Diff line number Diff line change @@ -3675,6 +3675,7 @@ ifs.rb:
36753675#-----| -> self
36763676
36773677# 47| b
3678+ #-----| false -> else ...
36783679#-----| true -> self
36793680
36803681# 47| then ...
@@ -3689,6 +3690,9 @@ ifs.rb:
36893690# 48| "true"
36903691#-----| -> call to puts
36913692
3693+ # 49| else ...
3694+ #-----| -> if ...
3695+
36923696# 51| call to puts
36933697#-----| -> exit empty_else (normal)
36943698
@@ -4006,6 +4010,7 @@ loops.rb:
40064010#-----| -> exit m4 (normal)
40074011
40084012# 31| ... < ...
4013+ #-----| true -> do ...
40094014#-----| false -> while ...
40104015
40114016# 31| x
@@ -4014,6 +4019,9 @@ loops.rb:
40144019# 31| y
40154020#-----| -> ... < ...
40164021
4022+ # 31| do ...
4023+ #-----| -> x
4024+
40174025raise.rb:
40184026# 1| enter raise.rb
40194027#-----| -> ExceptionA
@@ -5116,9 +5124,20 @@ raise.rb:
51165124# 147| [ensure: raise] 3
51175125#-----| -> [ensure: raise] return
51185126
5127+ # 150| enter m13
5128+ #-----| -> ensure ...
5129+
51195130# 150| m13
51205131#-----| -> m14
51215132
5133+ # 150| exit m13
5134+
5135+ # 150| exit m13 (normal)
5136+ #-----| -> exit m13
5137+
5138+ # 151| ensure ...
5139+ #-----| -> exit m13 (normal)
5140+
51225141# 154| enter m14
51235142#-----| -> element
51245143
You can’t perform that action at this time.
0 commit comments