@@ -140,6 +140,25 @@ class SsaSourceField extends SsaSourceVariable {
140140 }
141141}
142142
143+ /** An SSA definition in a closure that captures a variable. */
144+ class SsaCapturedDefinition extends SsaImplicitEntryDefinition {
145+ SsaCapturedDefinition ( ) { captures ( this , _) }
146+
147+ override string toString ( ) { result = "SSA capture def(" + this .getSourceVariable ( ) + ")" }
148+
149+ /** Holds if this definition captures the value of `capturedvar`. */
150+ predicate captures ( SsaDefinition capturedvar ) { captures ( this , capturedvar ) }
151+
152+ /**
153+ * Gets a definition that ultimately defines the captured variable and is not itself a phi node.
154+ */
155+ SsaDefinition getAnUltimateCapturedDefinition ( ) {
156+ exists ( SsaDefinition capturedvar |
157+ captures ( this , capturedvar ) and result = capturedvar .getAnUltimateDefinition ( )
158+ )
159+ }
160+ }
161+
143162/**
144163 * Gets an access of the SSA source variable underlying this SSA variable
145164 * that can be reached from this SSA variable without passing through any
@@ -194,18 +213,25 @@ class SsaVariable extends Definition {
194213 predicate isLiveAtEndOfBlock ( BasicBlock b ) { ssaDefReachesEndOfBlock ( b , this ) }
195214
196215 /**
216+ * DEPRECATED.
217+ *
197218 * Gets an SSA variable whose value can flow to this one in one step. This
198219 * includes inputs to phi nodes, the prior definition of uncertain updates,
199220 * and the captured ssa variable for a closure variable.
200221 */
201- SsaVariable getAPhiInputOrPriorDef ( ) {
222+ deprecated SsaVariable getAPhiInputOrPriorDef ( ) {
202223 result = this .( SsaPhiNode ) .getAPhiInput ( ) or
203224 result = this .( SsaUncertainImplicitUpdate ) .getPriorDef ( ) or
204225 this .( SsaImplicitInit ) .captures ( result )
205226 }
206227
207- /** Gets a definition that ultimately defines this variable and is not itself a phi node. */
208- SsaVariable getAnUltimateDefinition ( ) {
228+ /**
229+ * DEPRECATED: Use `SsaCapturedDefinition::getAnUltimateCapturedDefinition()`
230+ * and/or `SsaDefinition::getAnUltimateDefinition()` instead.
231+ *
232+ * Gets a definition that ultimately defines this variable and is not itself a phi node.
233+ */
234+ deprecated SsaVariable getAnUltimateDefinition ( ) {
209235 result = this .getAPhiInputOrPriorDef * ( ) and not result instanceof SsaPhiNode
210236 }
211237}
@@ -319,6 +345,8 @@ class SsaUncertainImplicitUpdate extends SsaImplicitUpdate {
319345}
320346
321347/**
348+ * DEPRECATED: Use `SsaParameterInit`, `SsaImplicitEntryDefinition`, or `SsaCapturedDefinition` instead.
349+ *
322350 * An SSA variable that is defined by its initial value in the callable. This
323351 * includes initial values of parameters, fields, and closure variables.
324352 */
0 commit comments