@@ -1306,7 +1306,34 @@ abstract private class AbstractParameterNode extends Node {
1306
1306
* implicit `this` parameter is considered to have position `-1`, and
1307
1307
* pointer-indirection parameters are at further negative positions.
1308
1308
*/
1309
- abstract predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) ;
1309
+ predicate isSourceParameterOf ( Function f , ParameterPosition pos ) { none ( ) }
1310
+
1311
+ /**
1312
+ * Holds if this node is the parameter of `sc` at the specified position. The
1313
+ * implicit `this` parameter is considered to have position `-1`, and
1314
+ * pointer-indirection parameters are at further negative positions.
1315
+ */
1316
+ predicate isSummaryParameterOf (
1317
+ FlowSummaryImpl:: Public:: SummarizedCallable sc , ParameterPosition pos
1318
+ ) {
1319
+ none ( )
1320
+ }
1321
+
1322
+ /**
1323
+ * Holds if this node is the parameter of `c` at the specified position. The
1324
+ * implicit `this` parameter is considered to have position `-1`, and
1325
+ * pointer-indirection parameters are at further negative positions.
1326
+ */
1327
+ final predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) {
1328
+ this .isSummaryParameterOf ( c .asSummarizedCallable ( ) , pos )
1329
+ or
1330
+ exists ( Function f | this .isSourceParameterOf ( f , pos ) |
1331
+ not exists ( TSummarizedCallable ( f ) ) and
1332
+ c .asSourceCallable ( ) = f
1333
+ or
1334
+ c .asSummarizedCallable ( ) = f
1335
+ )
1336
+ }
1310
1337
1311
1338
/** Gets the `Parameter` associated with this node, if it exists. */
1312
1339
Parameter getParameter ( ) { none ( ) } // overridden by subclasses
@@ -1366,8 +1393,8 @@ private class IndirectInstructionParameterNode extends AbstractIndirectParameter
1366
1393
1367
1394
override Declaration getFunction ( ) { result = init .getEnclosingFunction ( ) }
1368
1395
1369
- override predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) {
1370
- this .getEnclosingCallable ( ) = f . getUnderlyingCallable ( ) and
1396
+ override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1397
+ this .getEnclosingCallable ( ) = f and
1371
1398
exists ( int argumentIndex , int indirectionIndex |
1372
1399
indirectPositionHasArgumentIndexAndIndex ( pos , argumentIndex , indirectionIndex ) and
1373
1400
indirectParameterNodeHasArgumentIndexAndIndex ( this , argumentIndex , indirectionIndex )
@@ -1424,9 +1451,8 @@ private class ExplicitParameterInstructionNode extends AbstractExplicitParameter
1424
1451
{
1425
1452
ExplicitParameterInstructionNode ( ) { exists ( instr .getParameter ( ) ) }
1426
1453
1427
- override predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) {
1428
- f .getUnderlyingCallable ( ) .( Function ) .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) =
1429
- instr .getParameter ( )
1454
+ override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1455
+ f .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) = instr .getParameter ( )
1430
1456
}
1431
1457
1432
1458
override string toStringImpl ( ) { result = instr .getParameter ( ) .toString ( ) }
@@ -1440,9 +1466,9 @@ class ThisParameterInstructionNode extends AbstractExplicitParameterNode,
1440
1466
{
1441
1467
ThisParameterInstructionNode ( ) { instr .getIRVariable ( ) instanceof IRThisVariable }
1442
1468
1443
- override predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) {
1469
+ override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1444
1470
pos .( DirectPosition ) .getIndex ( ) = - 1 and
1445
- instr .getEnclosingFunction ( ) = f . getUnderlyingCallable ( )
1471
+ instr .getEnclosingFunction ( ) = f
1446
1472
}
1447
1473
1448
1474
override string toStringImpl ( ) { result = "this" }
@@ -1460,8 +1486,10 @@ class SummaryParameterNode extends AbstractParameterNode, FlowSummaryNode {
1460
1486
FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
1461
1487
}
1462
1488
1463
- override predicate isParameterOf ( DataFlowCallable c , ParameterPosition p ) {
1464
- c .getUnderlyingCallable ( ) = this .getSummarizedCallable ( ) and
1489
+ override predicate isSummaryParameterOf (
1490
+ FlowSummaryImpl:: Public:: SummarizedCallable c , ParameterPosition p
1491
+ ) {
1492
+ c = this .getSummarizedCallable ( ) and
1465
1493
p = this .getPosition ( )
1466
1494
}
1467
1495
}
@@ -1471,12 +1499,9 @@ private class DirectBodyLessParameterNode extends AbstractExplicitParameterNode,
1471
1499
{
1472
1500
DirectBodyLessParameterNode ( ) { indirectionIndex = 0 }
1473
1501
1474
- override predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) {
1475
- exists ( Function func |
1476
- this .getFunction ( ) = func and
1477
- f .asSourceCallable ( ) = func and
1478
- func .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) = p
1479
- )
1502
+ override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1503
+ this .getFunction ( ) = f and
1504
+ f .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) = p
1480
1505
}
1481
1506
1482
1507
override Parameter getParameter ( ) { result = p }
@@ -1487,12 +1512,11 @@ private class IndirectBodyLessParameterNode extends AbstractIndirectParameterNod
1487
1512
{
1488
1513
IndirectBodyLessParameterNode ( ) { not this instanceof DirectBodyLessParameterNode }
1489
1514
1490
- override predicate isParameterOf ( DataFlowCallable f , ParameterPosition pos ) {
1491
- exists ( Function func , int argumentPosition |
1492
- this .getFunction ( ) = func and
1493
- f .asSourceCallable ( ) = func and
1494
- indirectPositionHasArgumentIndexAndIndex ( pos , argumentPosition , indirectionIndex ) and
1495
- func .getParameter ( argumentPosition ) = p
1515
+ override predicate isSourceParameterOf ( Function f , ParameterPosition pos ) {
1516
+ exists ( int argumentPosition |
1517
+ this .getFunction ( ) = f and
1518
+ f .getParameter ( argumentPosition ) = p and
1519
+ indirectPositionHasArgumentIndexAndIndex ( pos , argumentPosition , indirectionIndex )
1496
1520
)
1497
1521
}
1498
1522
0 commit comments