@@ -500,7 +500,7 @@ module LocalFlow {
500
500
* inter-procedurality or field-sensitivity.
501
501
*/
502
502
predicate excludeFromExposedRelations ( Node n ) {
503
- n instanceof SummaryNode or
503
+ n instanceof FlowSummaryNode or
504
504
n instanceof ImplicitCapturedArgumentNode
505
505
}
506
506
@@ -559,7 +559,8 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
559
559
or
560
560
LocalFlow:: localFlowCapturedVarStep ( nodeFrom , nodeTo )
561
561
or
562
- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom , nodeTo , true )
562
+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom .( FlowSummaryNode ) .getSummaryNode ( ) ,
563
+ nodeTo .( FlowSummaryNode ) .getSummaryNode ( ) , true )
563
564
or
564
565
nodeTo .( ObjectCreationNode ) .getPreUpdateNode ( ) = nodeFrom .( ObjectInitializerNode )
565
566
}
@@ -805,7 +806,8 @@ private module Cached {
805
806
806
807
// Add artificial dependencies to enforce all cached predicates are evaluated
807
808
// in the "DataFlowImplCommon stage"
808
- private predicate forceCaching ( ) {
809
+ cached
810
+ predicate forceCaching ( ) {
809
811
TaintTrackingPrivate:: forceCachingInSameStage ( ) or
810
812
exists ( any ( NodeImpl n ) .getTypeImpl ( ) ) or
811
813
exists ( any ( NodeImpl n ) .getControlFlowNodeImpl ( ) ) or
@@ -815,10 +817,7 @@ private module Cached {
815
817
816
818
cached
817
819
newtype TNode =
818
- TExprNode ( ControlFlow:: Nodes:: ElementNode cfn ) {
819
- forceCaching ( ) and
820
- cfn .getElement ( ) instanceof Expr
821
- } or
820
+ TExprNode ( ControlFlow:: Nodes:: ElementNode cfn ) { cfn .getElement ( ) instanceof Expr } or
822
821
TCilExprNode ( CIL:: Expr e ) { e .getImplementation ( ) instanceof CIL:: BestImplementation } or
823
822
TCilSsaDefinitionExtNode ( CilSsaImpl:: DefinitionExt def ) or
824
823
TSsaDefinitionExtNode ( SsaImpl:: DefinitionExt def ) {
@@ -867,12 +866,7 @@ private module Cached {
867
866
)
868
867
)
869
868
} or
870
- TSummaryNode ( DataFlowSummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
871
- FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
872
- } or
873
- TSummaryParameterNode ( DataFlowSummarizedCallable c , ParameterPosition pos ) {
874
- FlowSummaryImpl:: Private:: summaryParameterNodeRange ( c , pos )
875
- } or
869
+ TFlowSummaryNode ( FlowSummaryImpl:: Private:: SummaryNode sn ) or
876
870
TParamsArgumentNode ( ControlFlow:: Node callCfn ) {
877
871
callCfn = any ( Call c | isParamsArg ( c , _, _) ) .getAControlFlowNode ( )
878
872
}
@@ -977,9 +971,7 @@ predicate nodeIsHidden(Node n) {
977
971
or
978
972
n instanceof MallocNode
979
973
or
980
- n instanceof SummaryNode
981
- or
982
- n instanceof SummaryParameterNode
974
+ n instanceof FlowSummaryNode
983
975
or
984
976
n instanceof ParamsArgumentNode
985
977
or
@@ -1132,29 +1124,28 @@ private module ParameterNodes {
1132
1124
}
1133
1125
1134
1126
/** A parameter for a library callable with a flow summary. */
1135
- class SummaryParameterNode extends ParameterNodeImpl , TSummaryParameterNode {
1136
- private FlowSummaryImpl:: Public:: SummarizedCallable sc ;
1137
- private ParameterPosition pos_ ;
1127
+ class SummaryParameterNode extends ParameterNodeImpl , FlowSummaryNode {
1128
+ SummaryParameterNode ( ) {
1129
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , _)
1130
+ }
1138
1131
1139
- SummaryParameterNode ( ) { this = TSummaryParameterNode ( sc , pos_ ) }
1132
+ private ParameterPosition getPosition ( ) {
1133
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
1134
+ }
1140
1135
1141
1136
override predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) {
1142
- sc = c .asSummarizedCallable ( ) and pos = pos_
1137
+ this . getSummarizedCallable ( ) = c .asSummarizedCallable ( ) and pos = this . getPosition ( )
1143
1138
}
1144
1139
1145
- override DataFlowCallable getEnclosingCallableImpl ( ) { result .asSummarizedCallable ( ) = sc }
1146
-
1147
1140
override Type getTypeImpl ( ) {
1148
- exists ( int i | pos_ .getPosition ( ) = i and result = sc .getParameter ( i ) .getType ( ) )
1141
+ exists ( int i |
1142
+ this .getPosition ( ) .getPosition ( ) = i and
1143
+ result = this .getSummarizedCallable ( ) .getParameter ( i ) .getType ( )
1144
+ )
1149
1145
or
1150
- pos_ .isThisParameter ( ) and result = sc .getDeclaringType ( )
1146
+ this .getPosition ( ) .isThisParameter ( ) and
1147
+ result = this .getSummarizedCallable ( ) .getDeclaringType ( )
1151
1148
}
1152
-
1153
- override ControlFlow:: Node getControlFlowNodeImpl ( ) { none ( ) }
1154
-
1155
- override EmptyLocation getLocationImpl ( ) { any ( ) }
1156
-
1157
- override string toStringImpl ( ) { result = "parameter " + pos_ + " of " + sc }
1158
1149
}
1159
1150
}
1160
1151
@@ -1323,11 +1314,13 @@ private module ArgumentNodes {
1323
1314
override string toStringImpl ( ) { result = "[implicit array creation] " + callCfn }
1324
1315
}
1325
1316
1326
- private class SummaryArgumentNode extends SummaryNode , ArgumentNodeImpl {
1327
- SummaryArgumentNode ( ) { FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this , _) }
1317
+ private class SummaryArgumentNode extends FlowSummaryNode , ArgumentNodeImpl {
1318
+ SummaryArgumentNode ( ) {
1319
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( _, this .getSummaryNode ( ) , _)
1320
+ }
1328
1321
1329
1322
override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1330
- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , pos )
1323
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , pos )
1331
1324
}
1332
1325
}
1333
1326
}
@@ -1469,11 +1462,11 @@ private module ReturnNodes {
1469
1462
}
1470
1463
}
1471
1464
1472
- private class SummaryReturnNode extends SummaryNode , ReturnNode {
1465
+ private class SummaryReturnNode extends FlowSummaryNode , ReturnNode {
1473
1466
private ReturnKind rk ;
1474
1467
1475
1468
SummaryReturnNode ( ) {
1476
- FlowSummaryImpl:: Private:: summaryReturnNode ( this , rk ) and
1469
+ FlowSummaryImpl:: Private:: summaryReturnNode ( this . getSummaryNode ( ) , rk ) and
1477
1470
not rk instanceof JumpReturnKind
1478
1471
or
1479
1472
exists ( Parameter p , int pos |
@@ -1494,9 +1487,9 @@ private module ReturnNodes {
1494
1487
* Holds if summary node `n` is a post-update node for `out`/`ref` parameter `p`.
1495
1488
* In this case we adjust it to instead be a return node.
1496
1489
*/
1497
- private predicate summaryPostUpdateNodeIsOutOrRef ( SummaryNode n , Parameter p ) {
1498
- exists ( ParameterNodeImpl pn , DataFlowCallable c , ParameterPosition pos |
1499
- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( n , pn ) and
1490
+ private predicate summaryPostUpdateNodeIsOutOrRef ( FlowSummaryNode n , Parameter p ) {
1491
+ exists ( SummaryParameterNode pn , DataFlowCallable c , ParameterPosition pos |
1492
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( n . getSummaryNode ( ) , pn . getSummaryNode ( ) ) and
1500
1493
pn .isParameterOf ( c , pos ) and
1501
1494
p = c .asSummarizedCallable ( ) .getParameter ( pos .getPosition ( ) ) and
1502
1495
p .isOutOrRef ( )
@@ -1609,37 +1602,40 @@ private module OutNodes {
1609
1602
}
1610
1603
}
1611
1604
1612
- private class SummaryOutNode extends SummaryNode , OutNode {
1613
- SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this , _) }
1605
+ private class SummaryOutNode extends FlowSummaryNode , OutNode {
1606
+ SummaryOutNode ( ) { FlowSummaryImpl:: Private:: summaryOutNode ( _, this . getSummaryNode ( ) , _) }
1614
1607
1615
1608
override DataFlowCall getCall ( ReturnKind kind ) {
1616
- FlowSummaryImpl:: Private:: summaryOutNode ( result , this , kind )
1609
+ FlowSummaryImpl:: Private:: summaryOutNode ( result , this . getSummaryNode ( ) , kind )
1617
1610
}
1618
1611
}
1619
1612
}
1620
1613
1621
1614
import OutNodes
1622
1615
1623
1616
/** A data-flow node used to model flow summaries. */
1624
- class SummaryNode extends NodeImpl , TSummaryNode {
1625
- private FlowSummaryImpl:: Public:: SummarizedCallable c ;
1626
- private FlowSummaryImpl:: Private:: SummaryNodeState state ;
1617
+ class FlowSummaryNode extends NodeImpl , TFlowSummaryNode {
1618
+ FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = TFlowSummaryNode ( result ) }
1627
1619
1628
- SummaryNode ( ) { this = TSummaryNode ( c , state ) }
1620
+ FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
1621
+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
1622
+ }
1629
1623
1630
- override DataFlowCallable getEnclosingCallableImpl ( ) { result .asSummarizedCallable ( ) = c }
1624
+ override DataFlowCallable getEnclosingCallableImpl ( ) {
1625
+ result .asSummarizedCallable ( ) = this .getSummarizedCallable ( )
1626
+ }
1631
1627
1632
1628
override DataFlowType getDataFlowType ( ) {
1633
- result = FlowSummaryImpl:: Private:: summaryNodeType ( this )
1629
+ result = FlowSummaryImpl:: Private:: summaryNodeType ( this . getSummaryNode ( ) )
1634
1630
}
1635
1631
1636
1632
override DotNet:: Type getTypeImpl ( ) { none ( ) }
1637
1633
1638
1634
override ControlFlow:: Node getControlFlowNodeImpl ( ) { none ( ) }
1639
1635
1640
- override Location getLocationImpl ( ) { result = c .getLocation ( ) }
1636
+ override Location getLocationImpl ( ) { result = this . getSummarizedCallable ( ) .getLocation ( ) }
1641
1637
1642
- override string toStringImpl ( ) { result = "[summary] " + state + " in " + c }
1638
+ override string toStringImpl ( ) { result = this . getSummaryNode ( ) . toString ( ) }
1643
1639
}
1644
1640
1645
1641
/** A field or a property. */
@@ -1719,12 +1715,13 @@ predicate jumpStep(Node pred, Node succ) {
1719
1715
)
1720
1716
or
1721
1717
exists ( JumpReturnKind jrk , NonDelegateDataFlowCall call |
1722
- FlowSummaryImpl:: Private:: summaryReturnNode ( pred , jrk ) and
1718
+ FlowSummaryImpl:: Private:: summaryReturnNode ( pred . ( FlowSummaryNode ) . getSummaryNode ( ) , jrk ) and
1723
1719
jrk .getTarget ( ) = call .getATarget ( _) and
1724
1720
succ = getAnOutNode ( call , jrk .getTargetReturnKind ( ) )
1725
1721
)
1726
1722
or
1727
- FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred , succ )
1723
+ FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred .( FlowSummaryNode ) .getSummaryNode ( ) ,
1724
+ succ .( FlowSummaryNode ) .getSummaryNode ( ) )
1728
1725
}
1729
1726
1730
1727
private class StoreStepConfiguration extends ControlFlowReachabilityConfiguration {
@@ -1784,7 +1781,8 @@ predicate storeStep(Node node1, Content c, Node node2) {
1784
1781
c = getResultContent ( )
1785
1782
)
1786
1783
or
1787
- FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 , c , node2 )
1784
+ FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1785
+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
1788
1786
}
1789
1787
1790
1788
private class ReadStepConfiguration extends ControlFlowReachabilityConfiguration {
@@ -1907,7 +1905,8 @@ predicate readStep(Node node1, Content c, Node node2) {
1907
1905
)
1908
1906
)
1909
1907
or
1910
- FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 , c , node2 )
1908
+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1909
+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
1911
1910
}
1912
1911
1913
1912
/**
@@ -1920,7 +1919,7 @@ predicate clearsContent(Node n, Content c) {
1920
1919
or
1921
1920
fieldOrPropertyStore ( _, c , _, n .( ObjectInitializerNode ) .getInitializer ( ) , false )
1922
1921
or
1923
- FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n , c )
1922
+ FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
1924
1923
or
1925
1924
exists ( WithExpr we , ObjectInitializer oi , FieldOrProperty f |
1926
1925
oi = we .getInitializer ( ) and
@@ -1935,7 +1934,7 @@ predicate clearsContent(Node n, Content c) {
1935
1934
* at node `n`.
1936
1935
*/
1937
1936
predicate expectsContent ( Node n , ContentSet c ) {
1938
- FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n , c )
1937
+ FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
1939
1938
}
1940
1939
1941
1940
/**
@@ -2130,14 +2129,15 @@ private module PostUpdateNodes {
2130
2129
override string toStringImpl ( ) { result = "[post] " + cfn .toString ( ) }
2131
2130
}
2132
2131
2133
- private class SummaryPostUpdateNode extends SummaryNode , PostUpdateNode {
2132
+ private class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNode {
2134
2133
SummaryPostUpdateNode ( ) {
2135
- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , _) and
2134
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this . getSummaryNode ( ) , _) and
2136
2135
not summaryPostUpdateNodeIsOutOrRef ( this , _)
2137
2136
}
2138
2137
2139
2138
override Node getPreUpdateNode ( ) {
2140
- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , result )
2139
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) ,
2140
+ result .( FlowSummaryNode ) .getSummaryNode ( ) )
2141
2141
}
2142
2142
}
2143
2143
}
@@ -2233,7 +2233,7 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
2233
2233
call .getControlFlowNode ( ) )
2234
2234
)
2235
2235
or
2236
- receiver = call .( SummaryCall ) .getReceiver ( )
2236
+ receiver . ( FlowSummaryNode ) . getSummaryNode ( ) = call .( SummaryCall ) .getReceiver ( )
2237
2237
) and
2238
2238
exists ( kind )
2239
2239
}
0 commit comments