@@ -103,10 +103,9 @@ module ArgumentPassing {
103
103
* Used to limit the size of predicates.
104
104
*/
105
105
predicate connects ( CallNode call , CallableValue callable ) {
106
- exists ( NormalCall c , NonLibraryDataFlowCallable k |
106
+ exists ( NormalCall c |
107
107
call = c .getNode ( ) and
108
- callable = k .getCallableValue ( ) and
109
- k = c .getCallable ( )
108
+ callable = c .getCallable ( ) .getCallableValue ( )
110
109
)
111
110
}
112
111
@@ -322,31 +321,24 @@ class DataFlowCallable extends TDataFlowCallable {
322
321
/** Gets the name of this callable. */
323
322
string getName ( ) { none ( ) }
324
323
324
+ /** Gets a callable value for this callable, if any. */
325
+ CallableValue getCallableValue ( ) { none ( ) }
326
+
325
327
/** Gets the underlying library callable, if any. */
326
328
LibraryCallable asLibraryCallable ( ) { this = TLibraryCallable ( result ) }
327
329
328
330
Location getLocation ( ) { none ( ) }
329
331
}
330
332
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
-
341
333
/** A class representing a callable value. */
342
- class DataFlowCallableValue extends NonLibraryDataFlowCallable , TCallableValue {
334
+ class DataFlowCallableValue extends DataFlowCallable , TCallableValue {
343
335
CallableValue callable ;
344
336
345
337
DataFlowCallableValue ( ) { this = TCallableValue ( callable ) }
346
338
347
339
override string toString ( ) { result = callable .toString ( ) }
348
340
349
- override CallNode getANonLibraryCall ( ) { result = callable .getACall ( ) }
341
+ override CallNode getACall ( ) { result = callable .getACall ( ) }
350
342
351
343
override Scope getScope ( ) { result = callable .getScope ( ) }
352
344
@@ -358,14 +350,14 @@ class DataFlowCallableValue extends NonLibraryDataFlowCallable, TCallableValue {
358
350
}
359
351
360
352
/** A class representing a callable lambda. */
361
- class DataFlowLambda extends NonLibraryDataFlowCallable , TLambda {
353
+ class DataFlowLambda extends DataFlowCallable , TLambda {
362
354
Function lambda ;
363
355
364
356
DataFlowLambda ( ) { this = TLambda ( lambda ) }
365
357
366
358
override string toString ( ) { result = lambda .toString ( ) }
367
359
368
- override CallNode getANonLibraryCall ( ) { result = this .getCallableValue ( ) .getACall ( ) }
360
+ override CallNode getACall ( ) { result = this .getCallableValue ( ) .getACall ( ) }
369
361
370
362
override Scope getScope ( ) { result = lambda .getEvaluatingScope ( ) }
371
363
@@ -381,14 +373,14 @@ class DataFlowLambda extends NonLibraryDataFlowCallable, TLambda {
381
373
}
382
374
383
375
/** A class representing the scope in which a `ModuleVariableNode` appears. */
384
- class DataFlowModuleScope extends NonLibraryDataFlowCallable , TModule {
376
+ class DataFlowModuleScope extends DataFlowCallable , TModule {
385
377
Module mod ;
386
378
387
379
DataFlowModuleScope ( ) { this = TModule ( mod ) }
388
380
389
381
override string toString ( ) { result = mod .toString ( ) }
390
382
391
- override CallNode getANonLibraryCall ( ) { none ( ) }
383
+ override CallNode getACall ( ) { none ( ) }
392
384
393
385
override Scope getScope ( ) { result = mod }
394
386
@@ -525,7 +517,7 @@ class NormalCall extends DataFlowSourceCall, TNormalCall {
525
517
* `self` parameter, and special method calls have special argument passing.
526
518
*/
527
519
class FunctionCall extends NormalCall {
528
- NonLibraryDataFlowCallable callable ;
520
+ DataFlowCallableValue callable ;
529
521
530
522
FunctionCall ( ) {
531
523
call = any ( FunctionValue f ) .getAFunctionCall ( ) and
@@ -539,7 +531,7 @@ class FunctionCall extends NormalCall {
539
531
540
532
/** A call to a lambda. */
541
533
class LambdaCall extends NormalCall {
542
- NonLibraryDataFlowCallable callable ;
534
+ DataFlowLambda callable ;
543
535
544
536
LambdaCall ( ) {
545
537
call = callable .getACall ( ) and
@@ -695,6 +687,19 @@ class SummaryParameterNode extends ParameterNodeImpl, TSummaryParameterNode {
695
687
}
696
688
697
689
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
+ }
698
703
}
699
704
700
705
/** A data-flow node used to model flow summaries. */
@@ -707,6 +712,17 @@ class SummaryNode extends Node, TSummaryNode {
707
712
override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
708
713
709
714
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
+ }
710
726
}
711
727
712
728
private class SummaryReturnNode extends SummaryNode , ReturnNode {
0 commit comments