@@ -203,7 +203,13 @@ module API {
203
203
/**
204
204
* Gets the data-flow node that gives rise to this node, if any.
205
205
*/
206
- DataFlow:: Node getInducingNode ( ) { this = Impl:: MkUse ( result ) }
206
+ DataFlow:: Node getInducingNode ( ) {
207
+ this = Impl:: MkUse ( result )
208
+ or
209
+ this = Impl:: MkDef ( result )
210
+ or
211
+ this = Impl:: MkMethodAccessNode ( result )
212
+ }
207
213
208
214
/** Gets the location of this node. */
209
215
Location getLocation ( ) {
@@ -250,15 +256,26 @@ module API {
250
256
override string toString ( ) { result = "root" }
251
257
}
252
258
259
+ private string tryGetPath ( Node node ) {
260
+ result = node .getPath ( )
261
+ or
262
+ not exists ( node .getPath ( ) ) and
263
+ result = "with no path"
264
+ }
265
+
253
266
/** A node corresponding to the use of an API component. */
254
267
class Use extends Node , Impl:: MkUse {
255
- override string toString ( ) {
256
- exists ( string type | type = "Use " |
257
- result = type + this .getPath ( )
258
- or
259
- not exists ( this .getPath ( ) ) and result = type + "with no path"
260
- )
261
- }
268
+ override string toString ( ) { result = "Use " + tryGetPath ( this ) }
269
+ }
270
+
271
+ /** A node corresponding to a value escaping into an API component. */
272
+ class Def extends Node , Impl:: MkDef {
273
+ override string toString ( ) { result = "Def " + tryGetPath ( this ) }
274
+ }
275
+
276
+ /** A node corresponding to the method being invoked at a method call. */
277
+ class MethodAccessNode extends Node , Impl:: MkMethodAccessNode {
278
+ override string toString ( ) { result = "MethodAccessNode " + tryGetPath ( this ) }
262
279
}
263
280
264
281
/** Gets the root node. */
@@ -304,7 +321,7 @@ module API {
304
321
/** The root of the API graph. */
305
322
MkRoot ( ) or
306
323
/** The method accessed at `call`, synthetically treated as a separate object. */
307
- MkMethodCall ( DataFlow:: CallNode call ) { isUse ( call ) } or
324
+ MkMethodAccessNode ( DataFlow:: CallNode call ) { isUse ( call ) } or
308
325
/** A use of an API member at the node `nd`. */
309
326
MkUse ( DataFlow:: Node nd ) { isUse ( nd ) } or
310
327
/** A value that escapes into an API at the node `nd` */
@@ -349,7 +366,7 @@ module API {
349
366
ref .asExpr ( ) = c and
350
367
read = c .getExpr ( )
351
368
)
352
- // note: method calls are not handled here as there is no DataFlow::Node for the intermediate MkMethodCall API node
369
+ // note: method calls are not handled here as there is no DataFlow::Node for the intermediate MkMethodAccessNode API node
353
370
}
354
371
355
372
pragma [ nomagic]
@@ -459,7 +476,9 @@ module API {
459
476
* Holds if there should be a `lbl`-edge from the given call to an argument.
460
477
*/
461
478
pragma [ nomagic]
462
- private predicate argumentStep ( string lbl , DataFlow:: CallNode call , DataFlowPrivate:: ArgumentNode argument ) {
479
+ private predicate argumentStep (
480
+ string lbl , DataFlow:: CallNode call , DataFlowPrivate:: ArgumentNode argument
481
+ ) {
463
482
exists ( DataFlowDispatch:: ArgumentPosition argPos |
464
483
argument .sourceArgumentOf ( call .asExpr ( ) , argPos ) and
465
484
lbl = getLabelFromArgumentPosition ( argPos )
@@ -470,7 +489,9 @@ module API {
470
489
* Holds if there should be a `lbl`-edge from the given callable to a parameter.
471
490
*/
472
491
pragma [ nomagic]
473
- private predicate parameterStep ( string lbl , DataFlow:: Node callable , DataFlowPrivate:: ParameterNodeImpl paramNode ) {
492
+ private predicate parameterStep (
493
+ string lbl , DataFlow:: Node callable , DataFlowPrivate:: ParameterNodeImpl paramNode
494
+ ) {
474
495
exists ( DataFlowDispatch:: ParameterPosition paramPos |
475
496
paramNode .isSourceParameterOf ( callable .asExpr ( ) .getExpr ( ) , paramPos ) and
476
497
lbl = getLabelFromParameterPosition ( paramPos )
@@ -564,11 +585,11 @@ module API {
564
585
pred = MkUse ( receiver ) and
565
586
useNodeReachesReceiver ( receiver , call ) and
566
587
lbl = Label:: method ( call .getMethodName ( ) ) and
567
- succ = MkMethodCall ( call )
588
+ succ = MkMethodAccessNode ( call )
568
589
)
569
590
or
570
591
// from method call node to return and arguments
571
- pred = MkMethodCall ( call ) and
592
+ pred = MkMethodAccessNode ( call ) and
572
593
(
573
594
lbl = Label:: return ( ) and
574
595
succ = MkUse ( call )
0 commit comments