1010 * of `<var>` reaches the read.
1111 * - `phi=<var>`: there is an SSA phi definition of `<var>` whose BB
1212 * starts on this line.
13+ * - `exit-use=<var>`: a phi definition of `<var>` reaches the synthetic
14+ * normal-exit read through the ESSA adapter.
1315 */
1416
1517import python
@@ -19,7 +21,7 @@ import semmle.python.controlflow.internal.Cfg as Cfg
1921import utils.test.InlineExpectationsTest
2022
2123module SsaTest implements TestSig {
22- string getARelevantTag ( ) { result = [ "def" , "use" , "phi" ] }
24+ string getARelevantTag ( ) { result = [ "def" , "use" , "phi" , "exit-use" ] }
2325
2426 predicate hasActualResult ( Location location , string element , string tag , string value ) {
2527 // A `def=<id>` fires when an SSA WriteDefinition is at a CFG node
@@ -53,6 +55,18 @@ module SsaTest implements TestSig {
5355 element = bb .toString ( ) and
5456 value = phi .getSourceVariable ( ) .( SsaImpl:: SsaSourceVariable ) .getVariable ( ) .getId ( )
5557 )
58+ or
59+ exists ( SsaImpl:: PhiFunction phi , SsaImpl:: EssaVariable variable , CfgImpl:: BasicBlock bb ,
60+ Cfg:: ControlFlowNode exit |
61+ variable = phi and
62+ phi .definesAt ( _, bb , _) and
63+ variable .getAUse ( ) = exit and
64+ exit .isNormalExit ( ) and
65+ tag = "exit-use" and
66+ location = bb .getNode ( 0 ) .getLocation ( ) and
67+ element = bb .toString ( ) and
68+ value = phi .getSourceVariable ( ) .( SsaImpl:: SsaSourceVariable ) .getVariable ( ) .getId ( )
69+ )
5670 }
5771}
5872
0 commit comments