@@ -146,8 +146,13 @@ class NonLocalVariable extends PythonSsaSourceVariable {
146146 this .( LocalVariable ) .getScope ( ) .getEntryNode ( ) = result
147147 }
148148
149+ pragma [ noinline]
150+ Scope scope_as_local_variable ( ) {
151+ result = this .( LocalVariable ) .getScope ( )
152+ }
153+
149154 override CallNode redefinedAtCallSite ( ) {
150- result .getScope ( ) .getScope * ( ) = this .( LocalVariable ) . getScope ( )
155+ result .getScope ( ) .getScope * ( ) = this .scope_as_local_variable ( )
151156 }
152157
153158}
@@ -173,7 +178,7 @@ class ClassLocalVariable extends PythonSsaSourceVariable {
173178class BuiltinVariable extends PythonSsaSourceVariable {
174179
175180 BuiltinVariable ( ) {
176- this instanceof GlobalVariable and
181+ this instanceof GlobalVariable and
177182 not exists ( this .( Variable ) .getAStore ( ) ) and
178183 not this .( Variable ) .getId ( ) = "__name__" and
179184 not this .( Variable ) .getId ( ) = "__package__" and
@@ -207,13 +212,21 @@ class ModuleVariable extends PythonSsaSourceVariable {
207212 )
208213 }
209214
210- override ControlFlowNode getAnImplicitUse ( ) {
215+ pragma [ noinline]
216+ CallNode global_variable_callnode ( ) {
217+ result .getScope ( ) = this .( GlobalVariable ) .getScope ( )
218+ }
219+
220+ pragma [ noinline]
221+ ImportMemberNode global_variable_import ( ) {
211222 result .getScope ( ) = this .( GlobalVariable ) .getScope ( ) and
212- (
213- result instanceof CallNode
214- or
215- import_from_dot_in_init ( result .( ImportMemberNode ) .getModule ( this .getName ( ) ) )
216- )
223+ import_from_dot_in_init ( result .( ImportMemberNode ) .getModule ( this .getName ( ) ) )
224+ }
225+
226+ override ControlFlowNode getAnImplicitUse ( ) {
227+ result = global_variable_callnode ( )
228+ or
229+ result = global_variable_import ( )
217230 or
218231 exists ( ImportTimeScope scope |
219232 scope .entryEdge ( result , _) |
@@ -292,8 +305,13 @@ class EscapingGlobalVariable extends ModuleVariable {
292305 result = this .innerScope ( ) .getEntryNode ( )
293306 }
294307
308+ pragma [ noinline]
309+ Scope scope_as_global_variable ( ) {
310+ result = this .( GlobalVariable ) .getScope ( )
311+ }
312+
295313 override CallNode redefinedAtCallSite ( ) {
296- result .( CallNode ) .getScope ( ) .getScope * ( ) = this .( GlobalVariable ) . getScope ( )
314+ result .( CallNode ) .getScope ( ) .getScope * ( ) = this .scope_as_global_variable ( )
297315 }
298316
299317}
@@ -324,8 +342,13 @@ class SpecialSsaSourceVariable extends PythonSsaSourceVariable {
324342 this .getScope ( ) .getEntryNode ( ) = result
325343 }
326344
345+ pragma [ noinline]
346+ Scope scope_as_global_variable ( ) {
347+ result = this .( GlobalVariable ) .getScope ( )
348+ }
349+
327350 override CallNode redefinedAtCallSite ( ) {
328- result .( CallNode ) .getScope ( ) .getScope * ( ) = this .( GlobalVariable ) . getScope ( )
351+ result .( CallNode ) .getScope ( ) .getScope * ( ) = this .scope_as_global_variable ( )
329352 }
330353
331354}
0 commit comments