@@ -1316,7 +1316,9 @@ newtype TDataFlowCall =
1316
1316
TNormalCall ( CallNode call , Function target , CallType type ) { resolveCall ( call , target , type ) } or
1317
1317
TPotentialLibraryCall ( CallNode call ) or
1318
1318
/** A synthesized call inside a summarized callable */
1319
- TSummaryCall ( FlowSummaryImpl:: Public:: SummarizedCallable c , Node receiver ) {
1319
+ TSummaryCall (
1320
+ FlowSummaryImpl:: Public:: SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNode receiver
1321
+ ) {
1320
1322
FlowSummaryImpl:: Private:: summaryCallbackRange ( c , receiver )
1321
1323
}
1322
1324
@@ -1448,12 +1450,12 @@ class PotentialLibraryCall extends ExtractedDataFlowCall, TPotentialLibraryCall
1448
1450
*/
1449
1451
class SummaryCall extends DataFlowCall , TSummaryCall {
1450
1452
private FlowSummaryImpl:: Public:: SummarizedCallable c ;
1451
- private Node receiver ;
1453
+ private FlowSummaryImpl :: Private :: SummaryNode receiver ;
1452
1454
1453
1455
SummaryCall ( ) { this = TSummaryCall ( c , receiver ) }
1454
1456
1455
1457
/** Gets the data flow node that this call targets. */
1456
- Node getReceiver ( ) { result = receiver }
1458
+ FlowSummaryImpl :: Private :: SummaryNode getReceiver ( ) { result = receiver }
1457
1459
1458
1460
override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
1459
1461
@@ -1486,44 +1488,35 @@ abstract class ParameterNodeImpl extends Node {
1486
1488
}
1487
1489
1488
1490
/** A parameter for a library callable with a flow summary. */
1489
- class SummaryParameterNode extends ParameterNodeImpl , TSummaryParameterNode {
1490
- private FlowSummaryImpl:: Public:: SummarizedCallable sc ;
1491
- private ParameterPosition pos ;
1491
+ class SummaryParameterNode extends ParameterNodeImpl , FlowSummaryNode {
1492
+ SummaryParameterNode ( ) {
1493
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , _)
1494
+ }
1492
1495
1493
- SummaryParameterNode ( ) { this = TSummaryParameterNode ( sc , pos ) }
1496
+ private ParameterPosition getPosition ( ) {
1497
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
1498
+ }
1494
1499
1495
1500
override Parameter getParameter ( ) { none ( ) }
1496
1501
1497
1502
override predicate isParameterOf ( DataFlowCallable c , ParameterPosition ppos ) {
1498
- sc = c .asLibraryCallable ( ) and ppos = pos
1499
- }
1500
-
1501
- override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = sc }
1502
-
1503
- override string toString ( ) { result = "parameter " + pos + " of " + sc }
1504
-
1505
- // Hack to return "empty location"
1506
- override predicate hasLocationInfo (
1507
- string file , int startline , int startcolumn , int endline , int endcolumn
1508
- ) {
1509
- file = "" and
1510
- startline = 0 and
1511
- startcolumn = 0 and
1512
- endline = 0 and
1513
- endcolumn = 0
1503
+ this .getSummarizedCallable ( ) = c .asLibraryCallable ( ) and ppos = this .getPosition ( )
1514
1504
}
1515
1505
}
1516
1506
1517
1507
/** A data-flow node used to model flow summaries. */
1518
- class SummaryNode extends Node , TSummaryNode {
1519
- private FlowSummaryImpl:: Public:: SummarizedCallable c ;
1520
- private FlowSummaryImpl:: Private:: SummaryNodeState state ;
1508
+ class FlowSummaryNode extends Node , TFlowSummaryNode {
1509
+ FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
1521
1510
1522
- SummaryNode ( ) { this = TSummaryNode ( c , state ) }
1511
+ FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
1512
+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
1513
+ }
1523
1514
1524
- override DataFlowCallable getEnclosingCallable ( ) { result .asLibraryCallable ( ) = c }
1515
+ override DataFlowCallable getEnclosingCallable ( ) {
1516
+ result .asLibraryCallable ( ) = this .getSummarizedCallable ( )
1517
+ }
1525
1518
1526
- override string toString ( ) { result = "[summary] " + state + " in " + c }
1519
+ override string toString ( ) { result = this . getSummaryNode ( ) . toString ( ) }
1527
1520
1528
1521
// Hack to return "empty location"
1529
1522
override predicate hasLocationInfo (
@@ -1537,26 +1530,30 @@ class SummaryNode extends Node, TSummaryNode {
1537
1530
}
1538
1531
}
1539
1532
1540
- private class SummaryReturnNode extends SummaryNode , ReturnNode {
1533
+ private class SummaryReturnNode extends FlowSummaryNode , ReturnNode {
1541
1534
private ReturnKind rk ;
1542
1535
1543
- SummaryReturnNode ( ) { FlowSummaryImpl:: Private:: summaryReturnNode ( this , rk ) }
1536
+ SummaryReturnNode ( ) { FlowSummaryImpl:: Private:: summaryReturnNode ( this . getSummaryNode ( ) , rk ) }
1544
1537
1545
1538
override ReturnKind getKind ( ) { result = rk }
1546
1539
}
1547
1540
1548
- private class SummaryArgumentNode extends SummaryNode , ArgumentNode {
1549
- SummaryArgumentNode ( ) { FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this , _) }
1541
+ private class SummaryArgumentNode extends FlowSummaryNode , ArgumentNode {
1542
+ SummaryArgumentNode ( ) {
1543
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this .getSummaryNode ( ) , _)
1544
+ }
1550
1545
1551
1546
override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1552
- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , pos )
1547
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , pos )
1553
1548
}
1554
1549
}
1555
1550
1556
- private class SummaryPostUpdateNode extends SummaryNode , PostUpdateNodeImpl {
1557
- private Node pre ;
1551
+ private class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNodeImpl {
1552
+ private FlowSummaryNode pre ;
1558
1553
1559
- SummaryPostUpdateNode ( ) { FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , pre ) }
1554
+ SummaryPostUpdateNode ( ) {
1555
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) , pre .getSummaryNode ( ) )
1556
+ }
1560
1557
1561
1558
override Node getPreUpdateNode ( ) { result = pre }
1562
1559
}
@@ -1625,11 +1622,11 @@ private module OutNodes {
1625
1622
}
1626
1623
}
1627
1624
1628
- private class SummaryOutNode extends SummaryNode , OutNode {
1629
- SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this , _) }
1625
+ private class SummaryOutNode extends FlowSummaryNode , OutNode {
1626
+ SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this . getSummaryNode ( ) , _) }
1630
1627
1631
1628
override DataFlowCall getCall ( ReturnKind kind ) {
1632
- FlowSummaryImpl:: Private:: summaryOutNode ( result , this , kind )
1629
+ FlowSummaryImpl:: Private:: summaryOutNode ( result , this . getSummaryNode ( ) , kind )
1633
1630
}
1634
1631
}
1635
1632
}
0 commit comments