@@ -42,35 +42,23 @@ final class DataFlowCallable extends TDataFlowCallable {
42
42
Location getLocation ( ) { result = this .asCfgScope ( ) .getLocation ( ) }
43
43
}
44
44
45
- abstract class DataFlowCall extends TDataFlowCall {
46
- /** Gets the enclosing callable. */
47
- abstract DataFlowCallable getEnclosingCallable ( ) ;
48
-
49
- /** Gets the underlying source code call, if any. */
50
- abstract CallCfgNode asCall ( ) ;
51
-
52
- /** Gets a textual representation of this call. */
53
- abstract string toString ( ) ;
54
-
55
- /** Gets the location of this call. */
56
- abstract Location getLocation ( ) ;
57
- }
58
-
59
- final class NormalCall extends DataFlowCall , TNormalCall {
60
- private CallCfgNode c ;
45
+ final class DataFlowCall extends TDataFlowCall {
46
+ /** Gets the underlying call in the CFG, if any. */
47
+ CallExprCfgNode asCallExprCfgNode ( ) { this = TNormalCall ( result ) }
61
48
62
- NormalCall ( ) { this = TNormalCall ( c ) }
49
+ MethodCallExprCfgNode asMethodCallExprCfgNode ( ) { this = TMethodCall ( result ) }
63
50
64
- /** Gets the underlying call in the CFG, if any. */
65
- override CallCfgNode asCall ( ) { result = c }
51
+ ExprCfgNode asExprCfgNode ( ) {
52
+ result = this .asCallExprCfgNode ( ) or result = this .asMethodCallExprCfgNode ( )
53
+ }
66
54
67
- override DataFlowCallable getEnclosingCallable ( ) {
68
- result = TCfgScope ( c .getExpr ( ) .getEnclosingCfgScope ( ) )
55
+ DataFlowCallable getEnclosingCallable ( ) {
56
+ result = TCfgScope ( this . asExprCfgNode ( ) .getExpr ( ) .getEnclosingCfgScope ( ) )
69
57
}
70
58
71
- override string toString ( ) { result = c .toString ( ) }
59
+ string toString ( ) { result = this . asExprCfgNode ( ) .toString ( ) }
72
60
73
- override Location getLocation ( ) { result = c .getLocation ( ) }
61
+ Location getLocation ( ) { result = this . asExprCfgNode ( ) .getLocation ( ) }
74
62
}
75
63
76
64
module Node {
@@ -204,7 +192,7 @@ module Node {
204
192
ExprOutNode ( ) { this .asExpr ( ) instanceof CallExpr }
205
193
206
194
/** Gets the underlying call CFG node that includes this out node. */
207
- override DataFlowCall getCall ( ) { result .( NormalCall ) . asCall ( ) = this .getCfgNode ( ) }
195
+ override DataFlowCall getCall ( ) { result .asExprCfgNode ( ) = this .getCfgNode ( ) }
208
196
}
209
197
210
198
/**
@@ -331,7 +319,15 @@ module RustDataFlow implements InputSig<Location> {
331
319
final class ReturnKind = ReturnKindAlias ;
332
320
333
321
/** Gets a viable implementation of the target of the given `Call`. */
334
- DataFlowCallable viableCallable ( DataFlowCall c ) { none ( ) }
322
+ DataFlowCallable viableCallable ( DataFlowCall c ) {
323
+ exists ( Function f , string name | result .asCfgScope ( ) = f and name = f .getName ( ) .toString ( ) |
324
+ if f .getParamList ( ) .hasSelfParam ( )
325
+ then name = c .asMethodCallExprCfgNode ( ) .getMethodCallExpr ( ) .getNameRef ( ) .getText ( )
326
+ else
327
+ name =
328
+ c .asCallExprCfgNode ( ) .getCallExpr ( ) .getExpr ( ) .( PathExpr ) .getPath ( ) .getPart ( ) .toString ( )
329
+ )
330
+ }
335
331
336
332
/**
337
333
* Gets a node that can read the value returned from `call` with return kind
@@ -488,7 +484,9 @@ private module Cached {
488
484
TSsaNode ( SsaImpl:: DataFlowIntegration:: SsaNode node )
489
485
490
486
cached
491
- newtype TDataFlowCall = TNormalCall ( CallCfgNode c )
487
+ newtype TDataFlowCall =
488
+ TNormalCall ( CallExprCfgNode c ) or
489
+ TMethodCall ( MethodCallExprCfgNode c )
492
490
493
491
cached
494
492
newtype TOptionalContentSet =
0 commit comments