@@ -111,6 +111,45 @@ private predicate hasDefaultSideEffect(Call call, ParameterIndex i, boolean buff
111111 )
112112}
113113
114+ /**
115+ * A `Call` or `NewOrNewArrayExpr`.
116+ *
117+ * Both kinds of expression invoke a function as part of their evaluation. This class provides a
118+ * way to treat both kinds of function similarly, and to get the invoked `Function`.
119+ */
120+ class CallOrAllocationExpr extends Expr {
121+ CallOrAllocationExpr ( ) {
122+ this instanceof Call
123+ or
124+ this instanceof NewOrNewArrayExpr
125+ }
126+
127+ /** Gets the `Function` invoked by this expression, if known. */
128+ final Function getTarget ( ) {
129+ result = this .( Call ) .getTarget ( )
130+ or
131+ result = this .( NewOrNewArrayExpr ) .getAllocator ( )
132+ }
133+ }
134+
135+ /**
136+ * Returns the side effect opcode, if any, that represents any side effects not specifically modeled
137+ * by an argument side effect.
138+ */
139+ Opcode getCallSideEffectOpcode ( CallOrAllocationExpr expr ) {
140+ not exists ( expr .getTarget ( ) .( SideEffectFunction ) ) and result instanceof Opcode:: CallSideEffect
141+ or
142+ exists ( SideEffectFunction sideEffectFunction |
143+ sideEffectFunction = expr .getTarget ( ) and
144+ if not sideEffectFunction .hasOnlySpecificWriteSideEffects ( )
145+ then result instanceof Opcode:: CallSideEffect
146+ else (
147+ not sideEffectFunction .hasOnlySpecificReadSideEffects ( ) and
148+ result instanceof Opcode:: CallReadSideEffect
149+ )
150+ )
151+ }
152+
114153/**
115154 * Returns a side effect opcode for parameter index `i` of the specified call.
116155 *
0 commit comments