@@ -141,17 +141,48 @@ class LoopExprTree extends PostOrderTree instanceof LoopExpr {
141141 override predicate first ( AstNode node ) { first ( super .getBody ( ) , node ) }
142142
143143 override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
144- // Edge from the last node in the body to the loop itself
144+ // Edge back to the start for final expression and continue expressions
145145 last ( super .getBody ( ) , pred , c ) and
146- completionIsNormal ( c ) and
146+ ( completionIsNormal ( c ) or c instanceof ContinueCompletion ) and
147+ this .first ( succ )
148+ or
149+ // Edge for exiting the loop with a break expressions
150+ last ( super .getBody ( ) , pred , c ) and
151+ c instanceof BreakCompletion and
147152 succ = this
153+ }
154+ }
155+
156+ class ReturnExprTree extends PostOrderTree instanceof ReturnExpr {
157+ override predicate propagatesAbnormal ( AstNode child ) { child = super .getExpr ( ) }
158+
159+ override predicate first ( AstNode node ) {
160+ first ( super .getExpr ( ) , node )
161+ or
162+ not super .hasExpr ( ) and node = this
163+ }
164+
165+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
166+ last ( super .getExpr ( ) , pred , c ) and succ = this
167+ }
168+ }
169+
170+ class BreakExprTree extends PostOrderTree instanceof BreakExpr {
171+ override predicate propagatesAbnormal ( AstNode child ) { child = super .getExpr ( ) }
172+
173+ override predicate first ( AstNode node ) {
174+ first ( super .getExpr ( ) , node )
148175 or
149- // Tie the knot with an edge from the loop back to the first node
150- pred = this and
151- first ( super .getBody ( ) , succ )
176+ not super .hasExpr ( ) and node = this
177+ }
178+
179+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
180+ last ( super .getExpr ( ) , pred , c ) and succ = this
152181 }
153182}
154183
184+ class ContinueExprTree extends LeafTree instanceof ContinueExpr { }
185+
155186class LiteralExprTree extends LeafTree instanceof LiteralExpr { }
156187
157188class PathExprTree extends LeafTree instanceof PathExpr { }
0 commit comments