@@ -94,13 +94,13 @@ class LogicalOrBinaryOpExprTree extends PreOrderTree instanceof BinaryExpr {
94
94
// Edge from the last node in the lhs to the first node in the rhs
95
95
last ( super .getLhs ( ) , pred , c ) and
96
96
first ( super .getRhs ( ) , succ ) and
97
- c .( BooleanCompletion ) .getValue ( ) = false
97
+ c .( BooleanCompletion ) .failed ( )
98
98
}
99
99
100
100
override predicate last ( AstNode node , Completion c ) {
101
101
// Lhs. as the last node
102
102
last ( super .getLhs ( ) , node , c ) and
103
- c .( BooleanCompletion ) .getValue ( ) = true
103
+ c .( BooleanCompletion ) .succeeded ( )
104
104
or
105
105
// Rhs. as the last node
106
106
last ( super .getRhs ( ) , node , c ) // and
@@ -124,13 +124,13 @@ class LogicalAndBinaryOpExprTree extends PreOrderTree instanceof BinaryExpr {
124
124
// Edge from the last node in the lhs to the first node in the rhs
125
125
last ( super .getLhs ( ) , pred , c ) and
126
126
first ( super .getRhs ( ) , succ ) and
127
- c .( BooleanCompletion ) .getValue ( ) = true
127
+ c .( BooleanCompletion ) .succeeded ( )
128
128
}
129
129
130
130
override predicate last ( AstNode node , Completion c ) {
131
131
// Lhs. as the last node
132
132
last ( super .getLhs ( ) , node , c ) and
133
- c .( BooleanCompletion ) .getValue ( ) = false
133
+ c .( BooleanCompletion ) .failed ( )
134
134
or
135
135
// Rhs. as the last node
136
136
last ( super .getRhs ( ) , node , c )
@@ -205,11 +205,11 @@ class IfExprTree extends PostOrderTree instanceof IfExpr {
205
205
// Edges from the condition to the branches
206
206
last ( super .getCondition ( ) , pred , c ) and
207
207
(
208
- first ( super .getThen ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = true
208
+ first ( super .getThen ( ) , succ ) and c .( BooleanCompletion ) .succeeded ( )
209
209
or
210
- first ( super .getElse ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = false
210
+ first ( super .getElse ( ) , succ ) and c .( BooleanCompletion ) .failed ( )
211
211
or
212
- not super .hasElse ( ) and succ = this and c .( BooleanCompletion ) .getValue ( ) = false
212
+ not super .hasElse ( ) and succ = this and c .( BooleanCompletion ) .failed ( )
213
213
)
214
214
or
215
215
// An edge from the then branch to the last node
@@ -272,6 +272,52 @@ class LoopExprTree extends PostOrderTree instanceof LoopExpr {
272
272
}
273
273
}
274
274
275
+ class MatchArmTree extends ControlFlowTree instanceof MatchArm {
276
+ override predicate propagatesAbnormal ( AstNode child ) { child = super .getExpr ( ) }
277
+
278
+ override predicate first ( AstNode node ) { node = super .getPat ( ) }
279
+
280
+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
281
+ // Edge from pattern to guard/arm if match succeeds.
282
+ pred = super .getPat ( ) and
283
+ c .( MatchCompletion ) .succeeded ( ) and
284
+ ( if super .hasGuard ( ) then first ( super .getGuard ( ) , succ ) else first ( super .getExpr ( ) , succ ) )
285
+ or
286
+ // Edge from guard to arm if the guard succeeds.
287
+ last ( super .getGuard ( ) , pred , c ) and
288
+ first ( super .getExpr ( ) , succ ) and
289
+ c .( BooleanCompletion ) .succeeded ( )
290
+ }
291
+
292
+ override predicate last ( AstNode node , Completion c ) {
293
+ node = super .getPat ( ) and c .( MatchCompletion ) .failed ( )
294
+ or
295
+ last ( super .getGuard ( ) , node , c ) and c .( BooleanCompletion ) .failed ( )
296
+ or
297
+ last ( super .getExpr ( ) , node , c )
298
+ }
299
+ }
300
+
301
+ class MatchExprTree extends PostOrderTree instanceof MatchExpr {
302
+ override predicate propagatesAbnormal ( AstNode child ) { child = super .getABranch ( ) .getExpr ( ) }
303
+
304
+ override predicate first ( AstNode node ) { first ( super .getExpr ( ) , node ) }
305
+
306
+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
307
+ // Edge from the scrutinee to the first arm.
308
+ last ( super .getExpr ( ) , pred , c ) and succ = super .getBranch ( 0 ) .getPat ( )
309
+ or
310
+ // Edge from a failed match/guard in one arm to the beginning of the next arm.
311
+ exists ( int i |
312
+ last ( super .getBranch ( i ) , pred , c ) and
313
+ first ( super .getBranch ( i + 1 ) , succ ) and
314
+ c .( ConditionalCompletion ) .failed ( )
315
+ )
316
+ or
317
+ exists ( int i | last ( super .getBranch ( i ) , pred , c ) and succ = this and completionIsSimple ( c ) )
318
+ }
319
+ }
320
+
275
321
class MethodCallExprTree extends StandardPostOrderTree instanceof MethodCallExpr {
276
322
override ControlFlowTree getChildNode ( int i ) {
277
323
result = super .getReceiver ( ) and
0 commit comments