@@ -578,6 +578,13 @@ cached module PointsToInternal {
578578 )
579579 or
580580 /* Undefined variable */
581+ undefined_variable ( def , context , value , origin )
582+ or
583+ /* Builtin not defined in outer scope */
584+ builtin_not_in_outer_scope ( def , context , value , origin )
585+ }
586+
587+ private predicate undefined_variable ( ScopeEntryDefinition def , PointsToContext context , ObjectInternal value , ControlFlowNode origin ) {
581588 exists ( Scope scope |
582589 not def .getVariable ( ) .getName ( ) = "__name__" and
583590 not def .getVariable ( ) .isMetaVariable ( ) and
@@ -587,8 +594,9 @@ cached module PointsToInternal {
587594 def .getSourceVariable ( ) instanceof LocalVariable and ( context .isImport ( ) or context .isRuntime ( ) or context .isMain ( ) )
588595 ) and
589596 value = ObjectInternal:: undefined ( ) and origin = def .getDefiningNode ( )
590- or
591- /* Builtin not defined in outer scope */
597+ }
598+
599+ private predicate builtin_not_in_outer_scope ( ScopeEntryDefinition def , PointsToContext context , ObjectInternal value , ControlFlowNode origin ) {
592600 exists ( Module mod , GlobalVariable var |
593601 var = def .getSourceVariable ( ) and
594602 mod = def .getScope ( ) .getEnclosingModule ( ) and
@@ -1113,8 +1121,17 @@ module InterProceduralPointsTo {
11131121 * Transfer of values from the callsite to the callee, for enclosing variables, but not arguments/parameters. */
11141122 pragma [ noinline]
11151123 private predicate callsite_entry_value_transfer ( EssaVariable caller_var , PointsToContext caller , ScopeEntryDefinition entry_def , PointsToContext callee ) {
1116- entry_def .getSourceVariable ( ) = caller_var .getSourceVariable ( ) and
1117- callsite_calls_function ( caller_var .getAUse ( ) , caller , entry_def .getScope ( ) , callee , _)
1124+ exists ( ControlFlowNode use , SsaSourceVariable var |
1125+ var_and_use ( caller_var , use , var ) and
1126+ entry_def .getSourceVariable ( ) = var and
1127+ callsite_calls_function ( use , caller , entry_def .getScope ( ) , callee , _)
1128+ )
1129+ }
1130+
1131+ pragma [ nomagic]
1132+ private predicate var_and_use ( EssaVariable caller_var , ControlFlowNode use , SsaSourceVariable var ) {
1133+ use = caller_var .getAUse ( ) and
1134+ var = caller_var .getSourceVariable ( )
11181135 }
11191136
11201137 /** Helper for `scope_entry_value_transfer`. */
0 commit comments