@@ -35,24 +35,22 @@ predicate accessPathCostLimits(int apLimit, int tupleLimit) {
35
35
* calls. For this reason, we cannot reuse the code from `DataFlowImpl.qll` directly.
36
36
*/
37
37
private module LambdaFlow {
38
- private predicate viableParamNonLambda ( DataFlowCall call , int i , ParameterNodeExt p ) {
38
+ private predicate viableParamNonLambda ( DataFlowCall call , int i , ParamNode p ) {
39
39
p .isParameterOf ( viableCallable ( call ) , i )
40
40
}
41
41
42
- private predicate viableParamLambda ( DataFlowCall call , int i , ParameterNodeExt p ) {
42
+ private predicate viableParamLambda ( DataFlowCall call , int i , ParamNode p ) {
43
43
p .isParameterOf ( viableCallableLambda ( call , _) , i )
44
44
}
45
45
46
- private predicate viableParamArgNonLambda (
47
- DataFlowCall call , ParameterNodeExt p , ArgumentNodeExt arg
48
- ) {
46
+ private predicate viableParamArgNonLambda ( DataFlowCall call , ParamNode p , ArgNode arg ) {
49
47
exists ( int i |
50
48
viableParamNonLambda ( call , i , p ) and
51
49
arg .argumentOf ( call , i )
52
50
)
53
51
}
54
52
55
- private predicate viableParamArgLambda ( DataFlowCall call , ParameterNodeExt p , ArgumentNodeExt arg ) {
53
+ private predicate viableParamArgLambda ( DataFlowCall call , ParamNode p , ArgNode arg ) {
56
54
exists ( int i |
57
55
viableParamLambda ( call , i , p ) and
58
56
arg .argumentOf ( call , i )
@@ -120,7 +118,7 @@ private module LambdaFlow {
120
118
boolean toJump , DataFlowCallOption lastCall
121
119
) {
122
120
revLambdaFlow0 ( lambdaCall , kind , node , t , toReturn , toJump , lastCall ) and
123
- if castNode ( node ) or node instanceof ArgumentNodeExt or node instanceof ReturnNode
121
+ if castNode ( node ) or node instanceof ArgNode or node instanceof ReturnNode
124
122
then compatibleTypes ( t , getNodeDataFlowType ( node ) )
125
123
else any ( )
126
124
}
@@ -178,7 +176,7 @@ private module LambdaFlow {
178
176
)
179
177
or
180
178
// flow into a callable
181
- exists ( ParameterNodeExt p , DataFlowCallOption lastCall0 , DataFlowCall call |
179
+ exists ( ParamNode p , DataFlowCallOption lastCall0 , DataFlowCall call |
182
180
revLambdaFlowIn ( lambdaCall , kind , p , t , toJump , lastCall0 ) and
183
181
(
184
182
if lastCall0 = TDataFlowCallNone ( ) and toJump = false
@@ -229,8 +227,8 @@ private module LambdaFlow {
229
227
230
228
pragma [ nomagic]
231
229
predicate revLambdaFlowIn (
232
- DataFlowCall lambdaCall , LambdaCallKind kind , ParameterNodeExt p , DataFlowType t ,
233
- boolean toJump , DataFlowCallOption lastCall
230
+ DataFlowCall lambdaCall , LambdaCallKind kind , ParamNode p , DataFlowType t , boolean toJump ,
231
+ DataFlowCallOption lastCall
234
232
) {
235
233
revLambdaFlow ( lambdaCall , kind , p , t , false , toJump , lastCall )
236
234
}
@@ -276,7 +274,7 @@ private module Cached {
276
274
predicate outNodeExt ( Node n ) {
277
275
n instanceof OutNode
278
276
or
279
- n .( PostUpdateNode ) .getPreUpdateNode ( ) instanceof ArgumentNodeExt
277
+ n .( PostUpdateNode ) .getPreUpdateNode ( ) instanceof ArgNode
280
278
}
281
279
282
280
cached
@@ -286,7 +284,7 @@ private module Cached {
286
284
OutNodeExt getAnOutNodeExt ( DataFlowCall call , ReturnKindExt k ) {
287
285
result = getAnOutNode ( call , k .( ValueReturnKind ) .getKind ( ) )
288
286
or
289
- exists ( ArgumentNodeExt arg |
287
+ exists ( ArgNode arg |
290
288
result .( PostUpdateNode ) .getPreUpdateNode ( ) = arg and
291
289
arg .argumentOf ( call , k .( ParamUpdateReturnKind ) .getPosition ( ) )
292
290
)
@@ -296,7 +294,7 @@ private module Cached {
296
294
predicate returnNodeExt ( Node n , ReturnKindExt k ) {
297
295
k = TValueReturn ( n .( ReturnNode ) .getKind ( ) )
298
296
or
299
- exists ( ParameterNodeExt p , int pos |
297
+ exists ( ParamNode p , int pos |
300
298
parameterValueFlowsToPreUpdate ( p , n ) and
301
299
p .isParameterOf ( _, pos ) and
302
300
k = TParamUpdate ( pos )
@@ -309,7 +307,7 @@ private module Cached {
309
307
cached
310
308
predicate castingNode ( Node n ) {
311
309
castNode ( n ) or
312
- n instanceof ParameterNodeExt or
310
+ n instanceof ParamNode or
313
311
n instanceof OutNodeExt or
314
312
// For reads, `x.f`, we want to check that the tracked type after the read (which
315
313
// is obtained by popping the head of the access path stack) is compatible with
@@ -346,7 +344,7 @@ private module Cached {
346
344
* The instance parameter is considered to have index `-1`.
347
345
*/
348
346
pragma [ nomagic]
349
- private predicate viableParam ( DataFlowCall call , int i , ParameterNodeExt p ) {
347
+ private predicate viableParam ( DataFlowCall call , int i , ParamNode p ) {
350
348
p .isParameterOf ( viableCallableExt ( call ) , i )
351
349
}
352
350
@@ -355,7 +353,7 @@ private module Cached {
355
353
* dispatch into account.
356
354
*/
357
355
cached
358
- predicate viableParamArg ( DataFlowCall call , ParameterNodeExt p , ArgumentNodeExt arg ) {
356
+ predicate viableParamArg ( DataFlowCall call , ParamNode p , ArgNode arg ) {
359
357
exists ( int i |
360
358
viableParam ( call , i , p ) and
361
359
arg .argumentOf ( call , i ) and
@@ -397,7 +395,7 @@ private module Cached {
397
395
* `read` indicates whether it is contents of `p` that can flow to `node`.
398
396
*/
399
397
pragma [ nomagic]
400
- private predicate parameterValueFlowCand ( ParameterNodeExt p , Node node , boolean read ) {
398
+ private predicate parameterValueFlowCand ( ParamNode p , Node node , boolean read ) {
401
399
p = node and
402
400
read = false
403
401
or
@@ -415,27 +413,25 @@ private module Cached {
415
413
)
416
414
or
417
415
// flow through: no prior read
418
- exists ( ArgumentNodeExt arg |
416
+ exists ( ArgNode arg |
419
417
parameterValueFlowArgCand ( p , arg , false ) and
420
418
argumentValueFlowsThroughCand ( arg , node , read )
421
419
)
422
420
or
423
421
// flow through: no read inside method
424
- exists ( ArgumentNodeExt arg |
422
+ exists ( ArgNode arg |
425
423
parameterValueFlowArgCand ( p , arg , read ) and
426
424
argumentValueFlowsThroughCand ( arg , node , false )
427
425
)
428
426
}
429
427
430
428
pragma [ nomagic]
431
- private predicate parameterValueFlowArgCand (
432
- ParameterNodeExt p , ArgumentNodeExt arg , boolean read
433
- ) {
429
+ private predicate parameterValueFlowArgCand ( ParamNode p , ArgNode arg , boolean read ) {
434
430
parameterValueFlowCand ( p , arg , read )
435
431
}
436
432
437
433
pragma [ nomagic]
438
- predicate parameterValueFlowsToPreUpdateCand ( ParameterNodeExt p , PostUpdateNode n ) {
434
+ predicate parameterValueFlowsToPreUpdateCand ( ParamNode p , PostUpdateNode n ) {
439
435
parameterValueFlowCand ( p , n .getPreUpdateNode ( ) , false )
440
436
}
441
437
@@ -447,7 +443,7 @@ private module Cached {
447
443
* `read` indicates whether it is contents of `p` that can flow to the return
448
444
* node.
449
445
*/
450
- predicate parameterValueFlowReturnCand ( ParameterNodeExt p , ReturnKind kind , boolean read ) {
446
+ predicate parameterValueFlowReturnCand ( ParamNode p , ReturnKind kind , boolean read ) {
451
447
exists ( ReturnNode ret |
452
448
parameterValueFlowCand ( p , ret , read ) and
453
449
kind = ret .getKind ( )
@@ -456,9 +452,9 @@ private module Cached {
456
452
457
453
pragma [ nomagic]
458
454
private predicate argumentValueFlowsThroughCand0 (
459
- DataFlowCall call , ArgumentNodeExt arg , ReturnKind kind , boolean read
455
+ DataFlowCall call , ArgNode arg , ReturnKind kind , boolean read
460
456
) {
461
- exists ( ParameterNodeExt param | viableParamArg ( call , param , arg ) |
457
+ exists ( ParamNode param | viableParamArg ( call , param , arg ) |
462
458
parameterValueFlowReturnCand ( param , kind , read )
463
459
)
464
460
}
@@ -469,14 +465,14 @@ private module Cached {
469
465
*
470
466
* `read` indicates whether it is contents of `arg` that can flow to `out`.
471
467
*/
472
- predicate argumentValueFlowsThroughCand ( ArgumentNodeExt arg , Node out , boolean read ) {
468
+ predicate argumentValueFlowsThroughCand ( ArgNode arg , Node out , boolean read ) {
473
469
exists ( DataFlowCall call , ReturnKind kind |
474
470
argumentValueFlowsThroughCand0 ( call , arg , kind , read ) and
475
471
out = getAnOutNode ( call , kind )
476
472
)
477
473
}
478
474
479
- predicate cand ( ParameterNodeExt p , Node n ) {
475
+ predicate cand ( ParamNode p , Node n ) {
480
476
parameterValueFlowCand ( p , n , _) and
481
477
(
482
478
parameterValueFlowReturnCand ( p , _, _)
@@ -503,7 +499,7 @@ private module Cached {
503
499
* If a read step was taken, then `read` captures the `Content`, the
504
500
* container type, and the content type.
505
501
*/
506
- predicate parameterValueFlow ( ParameterNodeExt p , Node node , ReadStepTypesOption read ) {
502
+ predicate parameterValueFlow ( ParamNode p , Node node , ReadStepTypesOption read ) {
507
503
parameterValueFlow0 ( p , node , read ) and
508
504
if node instanceof CastingNode
509
505
then
@@ -517,7 +513,7 @@ private module Cached {
517
513
}
518
514
519
515
pragma [ nomagic]
520
- private predicate parameterValueFlow0 ( ParameterNodeExt p , Node node , ReadStepTypesOption read ) {
516
+ private predicate parameterValueFlow0 ( ParamNode p , Node node , ReadStepTypesOption read ) {
521
517
p = node and
522
518
Cand:: cand ( p , _) and
523
519
read = TReadStepTypesNone ( )
@@ -542,34 +538,32 @@ private module Cached {
542
538
543
539
pragma [ nomagic]
544
540
private predicate parameterValueFlow0_0 (
545
- ReadStepTypesOption mustBeNone , ParameterNodeExt p , Node node , ReadStepTypesOption read
541
+ ReadStepTypesOption mustBeNone , ParamNode p , Node node , ReadStepTypesOption read
546
542
) {
547
543
// flow through: no prior read
548
- exists ( ArgumentNodeExt arg |
544
+ exists ( ArgNode arg |
549
545
parameterValueFlowArg ( p , arg , mustBeNone ) and
550
546
argumentValueFlowsThrough ( arg , read , node )
551
547
)
552
548
or
553
549
// flow through: no read inside method
554
- exists ( ArgumentNodeExt arg |
550
+ exists ( ArgNode arg |
555
551
parameterValueFlowArg ( p , arg , read ) and
556
552
argumentValueFlowsThrough ( arg , mustBeNone , node )
557
553
)
558
554
}
559
555
560
556
pragma [ nomagic]
561
- private predicate parameterValueFlowArg (
562
- ParameterNodeExt p , ArgumentNodeExt arg , ReadStepTypesOption read
563
- ) {
557
+ private predicate parameterValueFlowArg ( ParamNode p , ArgNode arg , ReadStepTypesOption read ) {
564
558
parameterValueFlow ( p , arg , read ) and
565
559
Cand:: argumentValueFlowsThroughCand ( arg , _, _)
566
560
}
567
561
568
562
pragma [ nomagic]
569
563
private predicate argumentValueFlowsThrough0 (
570
- DataFlowCall call , ArgumentNodeExt arg , ReturnKind kind , ReadStepTypesOption read
564
+ DataFlowCall call , ArgNode arg , ReturnKind kind , ReadStepTypesOption read
571
565
) {
572
- exists ( ParameterNodeExt param | viableParamArg ( call , param , arg ) |
566
+ exists ( ParamNode param | viableParamArg ( call , param , arg ) |
573
567
parameterValueFlowReturn ( param , kind , read )
574
568
)
575
569
}
@@ -583,7 +577,7 @@ private module Cached {
583
577
* container type, and the content type.
584
578
*/
585
579
pragma [ nomagic]
586
- predicate argumentValueFlowsThrough ( ArgumentNodeExt arg , ReadStepTypesOption read , Node out ) {
580
+ predicate argumentValueFlowsThrough ( ArgNode arg , ReadStepTypesOption read , Node out ) {
587
581
exists ( DataFlowCall call , ReturnKind kind |
588
582
argumentValueFlowsThrough0 ( call , arg , kind , read ) and
589
583
out = getAnOutNode ( call , kind )
@@ -603,7 +597,7 @@ private module Cached {
603
597
* value-preserving steps and a single read step, not taking call
604
598
* contexts into account, thus representing a getter-step.
605
599
*/
606
- predicate getterStep ( ArgumentNodeExt arg , Content c , Node out ) {
600
+ predicate getterStep ( ArgNode arg , Content c , Node out ) {
607
601
argumentValueFlowsThrough ( arg , TReadStepTypesSome ( _, c , _) , out )
608
602
}
609
603
@@ -616,7 +610,7 @@ private module Cached {
616
610
* container type, and the content type.
617
611
*/
618
612
private predicate parameterValueFlowReturn (
619
- ParameterNodeExt p , ReturnKind kind , ReadStepTypesOption read
613
+ ParamNode p , ReturnKind kind , ReadStepTypesOption read
620
614
) {
621
615
exists ( ReturnNode ret |
622
616
parameterValueFlow ( p , ret , read ) and
@@ -722,7 +716,7 @@ private module Cached {
722
716
* Holds if `p` can flow to the pre-update node associated with post-update
723
717
* node `n`, in the same callable, using only value-preserving steps.
724
718
*/
725
- private predicate parameterValueFlowsToPreUpdate ( ParameterNodeExt p , PostUpdateNode n ) {
719
+ private predicate parameterValueFlowsToPreUpdate ( ParamNode p , PostUpdateNode n ) {
726
720
parameterValueFlow ( p , n .getPreUpdateNode ( ) , TReadStepTypesNone ( ) )
727
721
}
728
722
@@ -778,8 +772,8 @@ private module Cached {
778
772
// Does the language-specific simpleLocalFlowStep already model flow
779
773
// from function input to output?
780
774
fromPre = getAnOutNode ( c , _) and
781
- toPre .( ArgumentNodeExt ) .argumentOf ( c , _) and
782
- simpleLocalFlowStep ( toPre .( ArgumentNodeExt ) , fromPre )
775
+ toPre .( ArgNode ) .argumentOf ( c , _) and
776
+ simpleLocalFlowStep ( toPre .( ArgNode ) , fromPre )
783
777
)
784
778
or
785
779
argumentValueFlowsThrough ( toPre , TReadStepTypesNone ( ) , fromPre )
@@ -827,7 +821,7 @@ private module Cached {
827
821
cached
828
822
newtype TReturnKindExt =
829
823
TValueReturn ( ReturnKind kind ) or
830
- TParamUpdate ( int pos ) { exists ( ParameterNodeExt p | p .isParameterOf ( _, pos ) ) }
824
+ TParamUpdate ( int pos ) { exists ( ParamNode p | p .isParameterOf ( _, pos ) ) }
831
825
832
826
cached
833
827
newtype TBooleanOption =
@@ -942,7 +936,7 @@ class CallContextSomeCall extends CallContextCall, TSomeCall {
942
936
override string toString ( ) { result = "CcSomeCall" }
943
937
944
938
override predicate relevantFor ( DataFlowCallable callable ) {
945
- exists ( ParameterNodeExt p | getNodeEnclosingCallable ( p ) = callable )
939
+ exists ( ParamNode p | getNodeEnclosingCallable ( p ) = callable )
946
940
}
947
941
948
942
override predicate matchesCall ( DataFlowCall call ) { any ( ) }
@@ -1005,8 +999,8 @@ LocalCallContext getLocalCallContext(CallContext ctx, DataFlowCallable callable)
1005
999
* The value of a parameter at function entry, viewed as a node in a data
1006
1000
* flow graph.
1007
1001
*/
1008
- class ParameterNodeExt extends Node {
1009
- ParameterNodeExt ( ) { parameterNode ( this , _, _) }
1002
+ class ParamNode extends Node {
1003
+ ParamNode ( ) { parameterNode ( this , _, _) }
1010
1004
1011
1005
/**
1012
1006
* Holds if this node is the parameter of callable `c` at the specified
@@ -1016,8 +1010,8 @@ class ParameterNodeExt extends Node {
1016
1010
}
1017
1011
1018
1012
/** A data-flow node that represents a call argument. */
1019
- class ArgumentNodeExt extends Node {
1020
- ArgumentNodeExt ( ) { argumentNode ( this , _, _) }
1013
+ class ArgNode extends Node {
1014
+ ArgNode ( ) { argumentNode ( this , _, _) }
1021
1015
1022
1016
/** Holds if this argument occurs at the given position in the given call. */
1023
1017
final predicate argumentOf ( DataFlowCall call , int pos ) { argumentNode ( this , call , pos ) }
0 commit comments