@@ -500,7 +500,7 @@ module LocalFlow {
500500 * inter-procedurality or field-sensitivity.
501501 */
502502 predicate excludeFromExposedRelations ( Node n ) {
503- n instanceof SummaryNode or
503+ n instanceof FlowSummaryNode or
504504 n instanceof ImplicitCapturedArgumentNode
505505 }
506506
@@ -559,7 +559,8 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
559559 or
560560 LocalFlow:: localFlowCapturedVarStep ( nodeFrom , nodeTo )
561561 or
562- FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom , nodeTo , true )
562+ FlowSummaryImpl:: Private:: Steps:: summaryLocalStep ( nodeFrom .( FlowSummaryNode ) .getSummaryNode ( ) ,
563+ nodeTo .( FlowSummaryNode ) .getSummaryNode ( ) , true )
563564 or
564565 nodeTo .( ObjectCreationNode ) .getPreUpdateNode ( ) = nodeFrom .( ObjectInitializerNode )
565566}
@@ -805,7 +806,8 @@ private module Cached {
805806
806807 // Add artificial dependencies to enforce all cached predicates are evaluated
807808 // in the "DataFlowImplCommon stage"
808- private predicate forceCaching ( ) {
809+ cached
810+ predicate forceCaching ( ) {
809811 TaintTrackingPrivate:: forceCachingInSameStage ( ) or
810812 exists ( any ( NodeImpl n ) .getTypeImpl ( ) ) or
811813 exists ( any ( NodeImpl n ) .getControlFlowNodeImpl ( ) ) or
@@ -815,10 +817,7 @@ private module Cached {
815817
816818 cached
817819 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
822821 TCilExprNode ( CIL:: Expr e ) { e .getImplementation ( ) instanceof CIL:: BestImplementation } or
823822 TCilSsaDefinitionExtNode ( CilSsaImpl:: DefinitionExt def ) or
824823 TSsaDefinitionExtNode ( SsaImpl:: DefinitionExt def ) {
@@ -867,12 +866,7 @@ private module Cached {
867866 )
868867 )
869868 } 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
876870 TParamsArgumentNode ( ControlFlow:: Node callCfn ) {
877871 callCfn = any ( Call c | isParamsArg ( c , _, _) ) .getAControlFlowNode ( )
878872 }
@@ -977,9 +971,7 @@ predicate nodeIsHidden(Node n) {
977971 or
978972 n instanceof MallocNode
979973 or
980- n instanceof SummaryNode
981- or
982- n instanceof SummaryParameterNode
974+ n instanceof FlowSummaryNode
983975 or
984976 n instanceof ParamsArgumentNode
985977 or
@@ -1132,29 +1124,28 @@ private module ParameterNodes {
11321124 }
11331125
11341126 /** 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+ }
11381131
1139- SummaryParameterNode ( ) { this = TSummaryParameterNode ( sc , pos_ ) }
1132+ private ParameterPosition getPosition ( ) {
1133+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
1134+ }
11401135
11411136 override predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) {
1142- sc = c .asSummarizedCallable ( ) and pos = pos_
1137+ this . getSummarizedCallable ( ) = c .asSummarizedCallable ( ) and pos = this . getPosition ( )
11431138 }
11441139
1145- override DataFlowCallable getEnclosingCallableImpl ( ) { result .asSummarizedCallable ( ) = sc }
1146-
11471140 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+ )
11491145 or
1150- pos_ .isThisParameter ( ) and result = sc .getDeclaringType ( )
1146+ this .getPosition ( ) .isThisParameter ( ) and
1147+ result = this .getSummarizedCallable ( ) .getDeclaringType ( )
11511148 }
1152-
1153- override ControlFlow:: Node getControlFlowNodeImpl ( ) { none ( ) }
1154-
1155- override EmptyLocation getLocationImpl ( ) { any ( ) }
1156-
1157- override string toStringImpl ( ) { result = "parameter " + pos_ + " of " + sc }
11581149 }
11591150}
11601151
@@ -1323,11 +1314,13 @@ private module ArgumentNodes {
13231314 override string toStringImpl ( ) { result = "[implicit array creation] " + callCfn }
13241315 }
13251316
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+ }
13281321
13291322 override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1330- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , pos )
1323+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , pos )
13311324 }
13321325 }
13331326}
@@ -1469,11 +1462,11 @@ private module ReturnNodes {
14691462 }
14701463 }
14711464
1472- private class SummaryReturnNode extends SummaryNode , ReturnNode {
1465+ private class SummaryReturnNode extends FlowSummaryNode , ReturnNode {
14731466 private ReturnKind rk ;
14741467
14751468 SummaryReturnNode ( ) {
1476- FlowSummaryImpl:: Private:: summaryReturnNode ( this , rk ) and
1469+ FlowSummaryImpl:: Private:: summaryReturnNode ( this . getSummaryNode ( ) , rk ) and
14771470 not rk instanceof JumpReturnKind
14781471 or
14791472 exists ( Parameter p , int pos |
@@ -1494,9 +1487,9 @@ private module ReturnNodes {
14941487 * Holds if summary node `n` is a post-update node for `out`/`ref` parameter `p`.
14951488 * In this case we adjust it to instead be a return node.
14961489 */
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
15001493 pn .isParameterOf ( c , pos ) and
15011494 p = c .asSummarizedCallable ( ) .getParameter ( pos .getPosition ( ) ) and
15021495 p .isOutOrRef ( )
@@ -1609,37 +1602,40 @@ private module OutNodes {
16091602 }
16101603 }
16111604
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 ( ) , _) }
16141607
16151608 override DataFlowCall getCall ( ReturnKind kind ) {
1616- FlowSummaryImpl:: Private:: summaryOutNode ( result , this , kind )
1609+ FlowSummaryImpl:: Private:: summaryOutNode ( result , this . getSummaryNode ( ) , kind )
16171610 }
16181611 }
16191612}
16201613
16211614import OutNodes
16221615
16231616/** 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 ) }
16271619
1628- SummaryNode ( ) { this = TSummaryNode ( c , state ) }
1620+ FlowSummaryImpl:: Public:: SummarizedCallable getSummarizedCallable ( ) {
1621+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
1622+ }
16291623
1630- override DataFlowCallable getEnclosingCallableImpl ( ) { result .asSummarizedCallable ( ) = c }
1624+ override DataFlowCallable getEnclosingCallableImpl ( ) {
1625+ result .asSummarizedCallable ( ) = this .getSummarizedCallable ( )
1626+ }
16311627
16321628 override DataFlowType getDataFlowType ( ) {
1633- result = FlowSummaryImpl:: Private:: summaryNodeType ( this )
1629+ result = FlowSummaryImpl:: Private:: summaryNodeType ( this . getSummaryNode ( ) )
16341630 }
16351631
16361632 override DotNet:: Type getTypeImpl ( ) { none ( ) }
16371633
16381634 override ControlFlow:: Node getControlFlowNodeImpl ( ) { none ( ) }
16391635
1640- override Location getLocationImpl ( ) { result = c .getLocation ( ) }
1636+ override Location getLocationImpl ( ) { result = this . getSummarizedCallable ( ) .getLocation ( ) }
16411637
1642- override string toStringImpl ( ) { result = "[summary] " + state + " in " + c }
1638+ override string toStringImpl ( ) { result = this . getSummaryNode ( ) . toString ( ) }
16431639}
16441640
16451641/** A field or a property. */
@@ -1719,12 +1715,13 @@ predicate jumpStep(Node pred, Node succ) {
17191715 )
17201716 or
17211717 exists ( JumpReturnKind jrk , NonDelegateDataFlowCall call |
1722- FlowSummaryImpl:: Private:: summaryReturnNode ( pred , jrk ) and
1718+ FlowSummaryImpl:: Private:: summaryReturnNode ( pred . ( FlowSummaryNode ) . getSummaryNode ( ) , jrk ) and
17231719 jrk .getTarget ( ) = call .getATarget ( _) and
17241720 succ = getAnOutNode ( call , jrk .getTargetReturnKind ( ) )
17251721 )
17261722 or
1727- FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred , succ )
1723+ FlowSummaryImpl:: Private:: Steps:: summaryJumpStep ( pred .( FlowSummaryNode ) .getSummaryNode ( ) ,
1724+ succ .( FlowSummaryNode ) .getSummaryNode ( ) )
17281725}
17291726
17301727private class StoreStepConfiguration extends ControlFlowReachabilityConfiguration {
@@ -1784,7 +1781,8 @@ predicate storeStep(Node node1, Content c, Node node2) {
17841781 c = getResultContent ( )
17851782 )
17861783 or
1787- FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 , c , node2 )
1784+ FlowSummaryImpl:: Private:: Steps:: summaryStoreStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1785+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
17881786}
17891787
17901788private class ReadStepConfiguration extends ControlFlowReachabilityConfiguration {
@@ -1907,7 +1905,8 @@ predicate readStep(Node node1, Content c, Node node2) {
19071905 )
19081906 )
19091907 or
1910- FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 , c , node2 )
1908+ FlowSummaryImpl:: Private:: Steps:: summaryReadStep ( node1 .( FlowSummaryNode ) .getSummaryNode ( ) , c ,
1909+ node2 .( FlowSummaryNode ) .getSummaryNode ( ) )
19111910}
19121911
19131912/**
@@ -1920,7 +1919,7 @@ predicate clearsContent(Node n, Content c) {
19201919 or
19211920 fieldOrPropertyStore ( _, c , _, n .( ObjectInitializerNode ) .getInitializer ( ) , false )
19221921 or
1923- FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n , c )
1922+ FlowSummaryImpl:: Private:: Steps:: summaryClearsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
19241923 or
19251924 exists ( WithExpr we , ObjectInitializer oi , FieldOrProperty f |
19261925 oi = we .getInitializer ( ) and
@@ -1935,7 +1934,7 @@ predicate clearsContent(Node n, Content c) {
19351934 * at node `n`.
19361935 */
19371936predicate expectsContent ( Node n , ContentSet c ) {
1938- FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n , c )
1937+ FlowSummaryImpl:: Private:: Steps:: summaryExpectsContent ( n . ( FlowSummaryNode ) . getSummaryNode ( ) , c )
19391938}
19401939
19411940/**
@@ -2130,14 +2129,15 @@ private module PostUpdateNodes {
21302129 override string toStringImpl ( ) { result = "[post] " + cfn .toString ( ) }
21312130 }
21322131
2133- private class SummaryPostUpdateNode extends SummaryNode , PostUpdateNode {
2132+ private class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNode {
21342133 SummaryPostUpdateNode ( ) {
2135- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , _) and
2134+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this . getSummaryNode ( ) , _) and
21362135 not summaryPostUpdateNodeIsOutOrRef ( this , _)
21372136 }
21382137
21392138 override Node getPreUpdateNode ( ) {
2140- FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , result )
2139+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) ,
2140+ result .( FlowSummaryNode ) .getSummaryNode ( ) )
21412141 }
21422142 }
21432143}
@@ -2233,7 +2233,7 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
22332233 call .getControlFlowNode ( ) )
22342234 )
22352235 or
2236- receiver = call .( SummaryCall ) .getReceiver ( )
2236+ receiver . ( FlowSummaryNode ) . getSummaryNode ( ) = call .( SummaryCall ) .getReceiver ( )
22372237 ) and
22382238 exists ( kind )
22392239}
0 commit comments