@@ -103,10 +103,9 @@ module ArgumentPassing {
103103 * Used to limit the size of predicates.
104104 */
105105 predicate connects ( CallNode call , CallableValue callable ) {
106- exists ( NormalCall c , NonLibraryDataFlowCallable k |
106+ exists ( NormalCall c |
107107 call = c .getNode ( ) and
108- callable = k .getCallableValue ( ) and
109- k = c .getCallable ( )
108+ callable = c .getCallable ( ) .getCallableValue ( )
110109 )
111110 }
112111
@@ -322,31 +321,24 @@ class DataFlowCallable extends TDataFlowCallable {
322321 /** Gets the name of this callable. */
323322 string getName ( ) { none ( ) }
324323
324+ /** Gets a callable value for this callable, if any. */
325+ CallableValue getCallableValue ( ) { none ( ) }
326+
325327 /** Gets the underlying library callable, if any. */
326328 LibraryCallable asLibraryCallable ( ) { this = TLibraryCallable ( result ) }
327329
328330 Location getLocation ( ) { none ( ) }
329331}
330332
331- /** A callable that is not synthesised. Either a CallableValue, a lambda or a module (only used to provide scopes for module variables). */
332- abstract class NonLibraryDataFlowCallable extends DataFlowCallable {
333- /** Gets a callable value for this callable, if one exists. */
334- abstract CallableValue getCallableValue ( ) ;
335-
336- abstract CallNode getANonLibraryCall ( ) ;
337-
338- final override CallNode getACall ( ) { result = this .getANonLibraryCall ( ) }
339- }
340-
341333/** A class representing a callable value. */
342- class DataFlowCallableValue extends NonLibraryDataFlowCallable , TCallableValue {
334+ class DataFlowCallableValue extends DataFlowCallable , TCallableValue {
343335 CallableValue callable ;
344336
345337 DataFlowCallableValue ( ) { this = TCallableValue ( callable ) }
346338
347339 override string toString ( ) { result = callable .toString ( ) }
348340
349- override CallNode getANonLibraryCall ( ) { result = callable .getACall ( ) }
341+ override CallNode getACall ( ) { result = callable .getACall ( ) }
350342
351343 override Scope getScope ( ) { result = callable .getScope ( ) }
352344
@@ -358,14 +350,14 @@ class DataFlowCallableValue extends NonLibraryDataFlowCallable, TCallableValue {
358350}
359351
360352/** A class representing a callable lambda. */
361- class DataFlowLambda extends NonLibraryDataFlowCallable , TLambda {
353+ class DataFlowLambda extends DataFlowCallable , TLambda {
362354 Function lambda ;
363355
364356 DataFlowLambda ( ) { this = TLambda ( lambda ) }
365357
366358 override string toString ( ) { result = lambda .toString ( ) }
367359
368- override CallNode getANonLibraryCall ( ) { result = this .getCallableValue ( ) .getACall ( ) }
360+ override CallNode getACall ( ) { result = this .getCallableValue ( ) .getACall ( ) }
369361
370362 override Scope getScope ( ) { result = lambda .getEvaluatingScope ( ) }
371363
@@ -381,14 +373,14 @@ class DataFlowLambda extends NonLibraryDataFlowCallable, TLambda {
381373}
382374
383375/** A class representing the scope in which a `ModuleVariableNode` appears. */
384- class DataFlowModuleScope extends NonLibraryDataFlowCallable , TModule {
376+ class DataFlowModuleScope extends DataFlowCallable , TModule {
385377 Module mod ;
386378
387379 DataFlowModuleScope ( ) { this = TModule ( mod ) }
388380
389381 override string toString ( ) { result = mod .toString ( ) }
390382
391- override CallNode getANonLibraryCall ( ) { none ( ) }
383+ override CallNode getACall ( ) { none ( ) }
392384
393385 override Scope getScope ( ) { result = mod }
394386
@@ -525,7 +517,7 @@ class NormalCall extends DataFlowSourceCall, TNormalCall {
525517 * `self` parameter, and special method calls have special argument passing.
526518 */
527519class FunctionCall extends NormalCall {
528- NonLibraryDataFlowCallable callable ;
520+ DataFlowCallableValue callable ;
529521
530522 FunctionCall ( ) {
531523 call = any ( FunctionValue f ) .getAFunctionCall ( ) and
@@ -539,7 +531,7 @@ class FunctionCall extends NormalCall {
539531
540532/** A call to a lambda. */
541533class LambdaCall extends NormalCall {
542- NonLibraryDataFlowCallable callable ;
534+ DataFlowLambda callable ;
543535
544536 LambdaCall ( ) {
545537 call = callable .getACall ( ) and
@@ -695,6 +687,19 @@ class SummaryParameterNode extends ParameterNodeImpl, TSummaryParameterNode {
695687 }
696688
697689 override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = sc }
690+
691+ override string toString ( ) { result = "parameter " + pos + " of " + sc }
692+
693+ // Hack to return "empty location"
694+ override predicate hasLocationInfo (
695+ string file , int startline , int startcolumn , int endline , int endcolumn
696+ ) {
697+ file = "" and
698+ startline = 0 and
699+ startcolumn = 0 and
700+ endline = 0 and
701+ endcolumn = 0
702+ }
698703}
699704
700705/** A data-flow node used to model flow summaries. */
@@ -707,6 +712,17 @@ class SummaryNode extends Node, TSummaryNode {
707712 override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
708713
709714 override string toString ( ) { result = "[summary] " + state + " in " + c }
715+
716+ // Hack to return "empty location"
717+ override predicate hasLocationInfo (
718+ string file , int startline , int startcolumn , int endline , int endcolumn
719+ ) {
720+ file = "" and
721+ startline = 0 and
722+ startcolumn = 0 and
723+ endline = 0 and
724+ endcolumn = 0
725+ }
710726}
711727
712728private class SummaryReturnNode extends SummaryNode , ReturnNode {
0 commit comments