Skip to content

Commit 7f1a718

Browse files
yoffCopilot
andcommitted
Python: preserve phi uses at module exit
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent c22345a commit 7f1a718

3 files changed

Lines changed: 3 additions & 2 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ class EssaVariable extends Ssa::SsaDefinition {
546546
*/
547547
Cfg::ControlFlowNode getAUse() {
548548
exists(CfgImpl::BasicBlock bb, int i |
549-
Impl::ssaDefReachesRead(this.getSourceVariable(), this.(Ssa::SsaWriteDefinition), bb, i) and
549+
Impl::ssaDefReachesRead(this.getSourceVariable(), this, bb, i) and
550550
bb.getNode(i) = result
551551
)
552552
}

python/ql/test/library-tests/dataflow-new-ssa/SsaTest.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module SsaTest implements TestSig {
6464
phi.definesAt(_, bb, _) and
6565
variable.getAUse() = exit and
6666
exit.isNormalExit() and
67+
exit.getScope() instanceof Module and
6768
tag = "exit-use" and
6869
location = bb.getNode(0).getLocation() and
6970
element = bb.toString() and

python/ql/test/library-tests/dataflow-new-ssa/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# on its `def` line.
1717

1818

19-
if object(): # $ phi=conditional_factory MISSING: exit-use=conditional_factory
19+
if object(): # $ phi=conditional_factory exit-use=conditional_factory
2020
from primary_backend import Factory as conditional_factory # $ def=conditional_factory
2121
else:
2222
from fallback_backend import Factory as conditional_factory # $ def=conditional_factory

0 commit comments

Comments
 (0)