@@ -45,24 +45,27 @@ private import codeql.controlflow.BasicBlock as BB
4545 */
4646private newtype TSsaSourceVariable =
4747 TPyVar ( Py:: Variable v ) {
48- // Has a use somewhere — read-relevant for SSA.
49- exists ( Cfg:: NameNode n | n .uses ( v ) )
50- or
51- // Or has a deletion (treated as a write that destroys the value).
52- exists ( Cfg:: NameNode n | n .deletes ( v ) )
53- or
54- // Or is a module-scope global written in this module — must be
55- // tracked even if never read locally, because importers may read
56- // it as an attribute on the module object.
57- v .getScope ( ) instanceof Py:: Module and
58- exists ( Cfg:: NameNode n | n .defines ( v ) )
59- or
60- // Or is a parameter — parameters must always have a
61- // `ParameterDefinition` for dataflow argument-routing to work,
62- // even if the parameter is never read in its scope. Mirrors
63- // legacy ESSA's `ParameterDefinition` (which fired for every
64- // parameter binding regardless of liveness).
65- exists ( Py:: Parameter p | p .asName ( ) = v .getAStore ( ) )
48+ not v .getALoad ( ) instanceof Py:: NameConstant and
49+ (
50+ // Has a use somewhere — read-relevant for SSA.
51+ exists ( Cfg:: NameNode n | n .uses ( v ) )
52+ or
53+ // Or has a deletion (treated as a write that destroys the value).
54+ exists ( Cfg:: NameNode n | n .deletes ( v ) )
55+ or
56+ // Or is a module-scope global written in this module — must be
57+ // tracked even if never read locally, because importers may read
58+ // it as an attribute on the module object.
59+ v .getScope ( ) instanceof Py:: Module and
60+ exists ( Cfg:: NameNode n | n .defines ( v ) )
61+ or
62+ // Or is a parameter — parameters must always have a
63+ // `ParameterDefinition` for dataflow argument-routing to work,
64+ // even if the parameter is never read in its scope. Mirrors
65+ // legacy ESSA's `ParameterDefinition` (which fired for every
66+ // parameter binding regardless of liveness).
67+ exists ( Py:: Parameter p | p .asName ( ) = v .getAStore ( ) )
68+ )
6669 }
6770
6871/**
0 commit comments