@@ -62,10 +62,13 @@ import CfgImpl
62
62
/** A trivial pattern that is always guaranteed to match. */
63
63
predicate trivialPat ( Pat p ) { p instanceof WildcardPat or p instanceof IdentPat }
64
64
65
+ class AsmExprTree extends LeafTree instanceof AsmExpr { }
66
+
65
67
class AwaitExprTree extends StandardPostOrderTree instanceof AwaitExpr {
66
68
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
67
69
}
68
70
71
+ // NOTE: `become` is a reserved but unused keyword.
69
72
class BecomeExprTree extends StandardPostOrderTree instanceof BecomeExpr {
70
73
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
71
74
}
@@ -142,7 +145,7 @@ class LogicalAndBinaryOpExprTree extends PreOrderTree instanceof BinaryExpr {
142
145
143
146
// NOTE: This covers both normal blocks `BlockExpr`, async blocks
144
147
// `AsyncBlockExpr`, and unsafe blocks `UnsafeBlockExpr`.
145
- class BaseBlockExprTree extends StandardPostOrderTree instanceof BlockExprBase {
148
+ class BlockExprBaseTree extends StandardPostOrderTree instanceof BlockExprBase {
146
149
override ControlFlowTree getChildNode ( int i ) {
147
150
result = super .getStatement ( i )
148
151
or
@@ -152,6 +155,10 @@ class BaseBlockExprTree extends StandardPostOrderTree instanceof BlockExprBase {
152
155
}
153
156
}
154
157
158
+ class BoxExprTree extends StandardPostOrderTree instanceof BoxExpr {
159
+ override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
160
+ }
161
+
155
162
class BreakExprTree extends PostOrderTree instanceof BreakExpr {
156
163
override predicate propagatesAbnormal ( AstNode child ) { child = super .getExpr ( ) }
157
164
@@ -168,8 +175,9 @@ class BreakExprTree extends PostOrderTree instanceof BreakExpr {
168
175
169
176
class CallExprTree extends StandardPostOrderTree instanceof CallExpr {
170
177
override ControlFlowTree getChildNode ( int i ) {
171
- result = super .getCallee ( ) and
172
- result = super .getArg ( i + 1 )
178
+ i = 0 and result = super .getCallee ( )
179
+ or
180
+ result = super .getArg ( i - 1 )
173
181
}
174
182
}
175
183
@@ -191,7 +199,7 @@ class ExprStmtTree extends StandardPreOrderTree instanceof ExprStmt {
191
199
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
192
200
}
193
201
194
- class FieldExprTree extends StandardPostOrderTree instanceof BecomeExpr {
202
+ class FieldExprTree extends StandardPostOrderTree instanceof FieldExpr {
195
203
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
196
204
}
197
205
@@ -371,10 +379,23 @@ class MethodCallExprTree extends StandardPostOrderTree instanceof MethodCallExpr
371
379
372
380
class OffsetOfExprTree extends LeafTree instanceof OffsetOfExpr { }
373
381
382
+ // This covers all patterns as they all extend `Pat`
374
383
class PatExprTree extends LeafTree instanceof Pat { }
375
384
376
385
class PathExprTree extends LeafTree instanceof PathExpr { }
377
386
387
+ class PrefixExprTree extends StandardPostOrderTree instanceof PrefixExpr {
388
+ override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
389
+ }
390
+
391
+ class RangeExprTree extends StandardPostOrderTree instanceof RangeExpr {
392
+ override ControlFlowTree getChildNode ( int i ) {
393
+ i = 0 and result = super .getLhs ( )
394
+ or
395
+ i = 1 and result = super .getRhs ( )
396
+ }
397
+ }
398
+
378
399
class RecordExprTree extends StandardPostOrderTree instanceof RecordExpr {
379
400
override ControlFlowTree getChildNode ( int i ) { result = super .getFld ( i ) .getExpr ( ) }
380
401
}
@@ -409,19 +430,19 @@ class TupleExprTree extends StandardPostOrderTree instanceof TupleExpr {
409
430
override ControlFlowTree getChildNode ( int i ) { result = super .getExpr ( i ) }
410
431
}
411
432
412
- class UnderscoreExprTree extends LeafTree instanceof UnderscoreExpr { }
433
+ class TypeRefTree extends LeafTree instanceof TypeRef { }
413
434
414
- class UnaryOpExprTree extends StandardPostOrderTree instanceof PrefixExpr {
415
- override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
416
- }
435
+ class UnderscoreExprTree extends LeafTree instanceof UnderscoreExpr { }
417
436
418
437
// A leaf tree for unimplemented nodes in the AST.
419
438
class UnimplementedTree extends LeafTree instanceof Unimplemented { }
420
439
440
+ // NOTE: `yield` is a reserved but unused keyword.
421
441
class YieldExprTree extends StandardPostOrderTree instanceof YieldExpr {
422
442
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
423
443
}
424
444
445
+ // NOTE: `yeet` is experimental and not a part of Rust.
425
446
class YeetExprTree extends StandardPostOrderTree instanceof YeetExpr {
426
447
override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
427
448
}
0 commit comments