@@ -47,12 +47,12 @@ private Element getRealParent(Expr expr) {
47
47
}
48
48
49
49
/**
50
- * Holds if `expr` should be ignored for the purposes of code generation due to
51
- * some property of `expr` itself. Unlike `ignoreExpr()`, this predicate does
52
- * not ignore an expression solely because it is a descendant of an ignored
53
- * element.
50
+ * Holds if `expr` and all of its descendants should be ignored for the purposes
51
+ * of IR generation due to some property of `expr` itself. Unlike
52
+ * `ignoreExpr()`, this predicate does not ignore an expression solely because
53
+ * it is a descendant of an ignored element.
54
54
*/
55
- private predicate ignoreExprLocal ( Expr expr ) {
55
+ private predicate ignoreExprAndDescendants ( Expr expr ) {
56
56
// Ignore parentless expressions
57
57
not exists ( getRealParent ( expr ) ) or
58
58
// Ignore the constants in SwitchCase, since their values are embedded in the
@@ -65,23 +65,32 @@ private predicate ignoreExprLocal(Expr expr) {
65
65
// node as its qualifier, but that `FieldAccess` does not have a child of its own.
66
66
// We'll ignore that `FieldAccess`, and supply the receiver as part of the calling
67
67
// context, much like we do with constructor calls.
68
- expr .getParent ( ) .( DestructorCall ) .getParent ( ) instanceof DestructorFieldDestruction
68
+ expr .getParent ( ) .( DestructorCall ) .getParent ( ) instanceof DestructorFieldDestruction or
69
+ exists ( NewArrayExpr newExpr |
70
+ // REVIEW: Ignore initializers for `NewArrayExpr` until we determine how to
71
+ // represent them.
72
+ newExpr .getInitializer ( ) .getFullyConverted ( ) = expr
73
+ )
69
74
}
70
75
71
76
/**
72
- * Holds if `expr` should be ignored for the purposes of IR generation.
77
+ * Holds if `expr` (not including its descendants) should be ignored for the
78
+ * purposes of IR generation.
73
79
*/
74
- private predicate ignoreExpr ( Expr expr ) {
75
- ignoreExprLocal ( expr ) or
76
- // Ignore all descendants of ignored elements as well.
77
- ignoreElement ( getRealParent ( expr ) )
80
+ private predicate ignoreExprOnly ( Expr expr ) {
81
+ exists ( NewOrNewArrayExpr newExpr |
82
+ // Ignore the allocator call, because we always synthesize it. Don't ignore
83
+ // its arguments, though, because we use them as part of the synthesis.
84
+ newExpr .getAllocatorCall ( ) = expr
85
+ )
78
86
}
79
87
80
88
/**
81
- * Holds if `element ` should be ignored for the purposes of IR generation.
89
+ * Holds if `expr ` should be ignored for the purposes of IR generation.
82
90
*/
83
- private predicate ignoreElement ( Element element ) {
84
- ignoreExpr ( element .( Expr ) )
91
+ private predicate ignoreExpr ( Expr expr ) {
92
+ ignoreExprOnly ( expr ) or
93
+ ignoreExprAndDescendants ( getRealParent * ( expr ) )
85
94
}
86
95
87
96
/**
@@ -216,6 +225,9 @@ newtype TTranslatedElement =
216
225
exists ( ConstructorFieldInit fieldInit |
217
226
fieldInit .getExpr ( ) .getFullyConverted ( ) = expr
218
227
) or
228
+ exists ( NewExpr newExpr |
229
+ newExpr .getInitializer ( ) .getFullyConverted ( ) = expr
230
+ ) or
219
231
exists ( ThrowExpr throw |
220
232
throw .getExpr ( ) .getFullyConverted ( ) = expr
221
233
)
@@ -298,6 +310,14 @@ newtype TTranslatedElement =
298
310
exists ( DeclStmt declStmt |
299
311
declStmt .getADeclarationEntry ( ) = entry
300
312
)
313
+ } or
314
+ // An allocator call in a `new` or `new[]` expression
315
+ TTranslatedAllocatorCall ( NewOrNewArrayExpr newExpr ) {
316
+ not ignoreExpr ( newExpr )
317
+ } or
318
+ // An allocation size for a `new` or `new[]` expression
319
+ TTranslatedAllocationSize ( NewOrNewArrayExpr newExpr ) {
320
+ not ignoreExpr ( newExpr )
301
321
}
302
322
303
323
/**
0 commit comments