@@ -149,6 +149,47 @@ module Ssa {
149149 }
150150 }
151151
152+ /**
153+ * Gets a read of the source variable underlying the SSA definition `def`
154+ * that can be reached from `def` without passing through any
155+ * other SSA definition or read. Example:
156+ *
157+ * ```csharp
158+ * int Field;
159+ *
160+ * void SetField(int i) {
161+ * this.Field = i;
162+ * Use(this.Field);
163+ * if (i > 0)
164+ * this.Field = i - 1;
165+ * else if (i < 0)
166+ * SetField(1);
167+ * Use(this.Field);
168+ * Use(this.Field);
169+ * }
170+ * ```
171+ *
172+ * - The read of `i` on line 4 can be reached from the explicit SSA
173+ * definition (wrapping an implicit entry definition) on line 3.
174+ * - The reads of `i` on lines 6 and 7 are not the first reads of any SSA
175+ * definition.
176+ * - The read of `this.Field` on line 5 can be reached from the explicit SSA
177+ * definition on line 4.
178+ * - The read of `this.Field` on line 10 can be reached from the phi node
179+ * between lines 9 and 10.
180+ * - The read of `this.Field` on line 11 is not the first read of any SSA
181+ * definition.
182+ *
183+ * Subsequent reads can be found by following the steps defined by
184+ * `AssignableRead.getANextRead()`.
185+ */
186+ AssignableRead ssaGetAFirstUse ( SsaDefinition def ) {
187+ exists ( ControlFlowNode cfn |
188+ SsaImpl:: firstReadSameVar ( def , cfn ) and
189+ result .getControlFlowNode ( ) = cfn
190+ )
191+ }
192+
152193 /**
153194 * A static single assignment (SSA) definition. Either an explicit variable
154195 * definition (`ExplicitDefinition`), an implicit variable definition
@@ -229,6 +270,8 @@ module Ssa {
229270 }
230271
231272 /**
273+ * DEPRECATED: Use `ssaGetAFirstUse` instead.
274+ *
232275 * Gets a read of the source variable underlying this SSA definition that
233276 * can be reached from this SSA definition without passing through any
234277 * other SSA definition or read. Example:
@@ -262,9 +305,11 @@ module Ssa {
262305 * Subsequent reads can be found by following the steps defined by
263306 * `AssignableRead.getANextRead()`.
264307 */
265- final AssignableRead getAFirstRead ( ) { result = this .getAFirstReadAtNode ( _) }
308+ deprecated final AssignableRead getAFirstRead ( ) { result = this .getAFirstReadAtNode ( _) }
266309
267310 /**
311+ * DEPRECATED: Use `ssaGetAFirstUse` instead.
312+ *
268313 * Gets a read of the source variable underlying this SSA definition at
269314 * control flow node `cfn` that can be reached from this SSA definition
270315 * without passing through any other SSA definition or read. Example:
@@ -298,7 +343,7 @@ module Ssa {
298343 * Subsequent reads can be found by following the steps defined by
299344 * `AssignableRead.getANextRead()`.
300345 */
301- final AssignableRead getAFirstReadAtNode ( ControlFlowNode cfn ) {
346+ deprecated final AssignableRead getAFirstReadAtNode ( ControlFlowNode cfn ) {
302347 SsaImpl:: firstReadSameVar ( this , cfn ) and
303348 result .getControlFlowNode ( ) = cfn
304349 }
0 commit comments