@@ -11,12 +11,7 @@ private newtype TNode =
1111 MkSsaNode ( SsaDefinition ssa ) or
1212 MkGlobalFunctionNode ( Function f ) or
1313 MkImplicitVarargsSlice ( CallExpr c ) { c .hasImplicitVarargs ( ) } or
14- MkSummarizedParameterNode ( SummarizedCallable c , int i ) {
15- FlowSummaryImpl:: Private:: summaryParameterNodeRange ( c , i )
16- } or
17- MkSummaryInternalNode ( SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
18- FlowSummaryImpl:: Private:: summaryNodeRange ( c , state )
19- }
14+ MkFlowSummaryNode ( FlowSummaryImpl:: Private:: SummaryNode sn )
2015
2116/** Nodes intended for only use inside the data-flow libraries. */
2217module Private {
@@ -30,9 +25,7 @@ module Private {
3025 not exists ( n .getEnclosingCallable ( ) ) and
3126 result .asFileScope ( ) = n .getFile ( )
3227 or
33- n = MkSummarizedParameterNode ( result .asSummarizedCallable ( ) , _)
34- or
35- n = MkSummaryInternalNode ( result .asSummarizedCallable ( ) , _)
28+ result .asSummarizedCallable ( ) = n .( FlowSummaryNode ) .getSummarizedCallable ( )
3629 }
3730
3831 /** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
@@ -52,7 +45,7 @@ module Private {
5245 ReturnNode ( ) {
5346 this .( Public:: ResultNode ) .getIndex ( ) = kind .getIndex ( )
5447 or
55- this .( SummaryNode ) .isReturn ( kind )
48+ this .( FlowSummaryNode ) .isReturn ( kind )
5649 }
5750
5851 /** Gets the kind of this returned value. */
@@ -72,33 +65,33 @@ module Private {
7265 /**
7366 * A data-flow node used to model flow summaries.
7467 */
75- class SummaryNode extends Node , MkSummaryInternalNode {
76- private SummarizedCallable c ;
77- private FlowSummaryImpl:: Private:: SummaryNodeState state ;
68+ class FlowSummaryNode extends Node , MkFlowSummaryNode {
69+ FlowSummaryImpl:: Private:: SummaryNode getSummaryNode ( ) { this = MkFlowSummaryNode ( result ) }
7870
79- SummaryNode ( ) { this = MkSummaryInternalNode ( c , state ) }
71+ SummarizedCallable getSummarizedCallable ( ) {
72+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
73+ }
8074
8175 override predicate hasLocationInfo ( string fp , int sl , int sc , int el , int ec ) {
82- c .hasLocationInfo ( fp , sl , sc , el , ec )
76+ this . getSummarizedCallable ( ) .hasLocationInfo ( fp , sl , sc , el , ec )
8377 }
8478
85- override string toString ( ) { result = "[summary] " + state + " in " + c }
79+ override string toString ( ) { result = this . getSummaryNode ( ) . toString ( ) }
8680
8781 /** Holds if this summary node is the `i`th argument of `call`. */
8882 predicate isArgumentOf ( DataFlowCall call , int i ) {
89- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , i )
83+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , i )
9084 }
9185
9286 /** Holds if this summary node is a return node. */
93- predicate isReturn ( ReturnKind kind ) { FlowSummaryImpl:: Private:: summaryReturnNode ( this , kind ) }
87+ predicate isReturn ( ReturnKind kind ) {
88+ FlowSummaryImpl:: Private:: summaryReturnNode ( this .getSummaryNode ( ) , kind )
89+ }
9490
9591 /** Holds if this summary node is an out node for `call`. */
96- predicate isOut ( DataFlowCall call ) { FlowSummaryImpl:: Private:: summaryOutNode ( call , this , _) }
97- }
98-
99- /** Gets the summary node corresponding to the callable `c` and state `state`. */
100- SummaryNode getSummaryNode ( SummarizedCallable c , FlowSummaryImpl:: Private:: SummaryNodeState state ) {
101- result = MkSummaryInternalNode ( c , state )
92+ predicate isOut ( DataFlowCall call ) {
93+ FlowSummaryImpl:: Private:: summaryOutNode ( call , this .getSummaryNode ( ) , _)
94+ }
10295 }
10396}
10497
@@ -661,31 +654,29 @@ module Public {
661654 * A summary node which represents a parameter in a function which doesn't
662655 * already have a parameter nodes.
663656 */
664- class SummarizedParameterNode extends ParameterNode , MkSummarizedParameterNode {
665- SummarizedCallable c ;
666- int i ;
657+ class SummarizedParameterNode extends ParameterNode , FlowSummaryNode {
658+ SummarizedParameterNode ( ) {
659+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , _)
660+ }
667661
668- SummarizedParameterNode ( ) { this = MkSummarizedParameterNode ( c , i ) }
662+ private int getPos ( ) {
663+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
664+ }
669665
670666 // There are no AST representations of summarized parameter nodes
671667 override ControlFlow:: Root getRoot ( ) { none ( ) }
672668
673669 override string getNodeKind ( ) { result = "external parameter node" }
674670
675671 override Type getType ( ) {
676- result = c . getType ( ) .getParameterType ( i )
672+ result = this . getSummarizedCallable ( ) . getType ( ) .getParameterType ( this . getPos ( ) )
677673 or
678- i = - 1 and result = c .asFunction ( ) .( Method ) .getReceiverType ( )
674+ this .getPos ( ) = - 1 and
675+ result = this .getSummarizedCallable ( ) .asFunction ( ) .( Method ) .getReceiverType ( )
679676 }
680677
681678 override predicate isParameterOf ( DataFlowCallable call , int idx ) {
682- c = call .asSummarizedCallable ( ) and i = idx
683- }
684-
685- override string toString ( ) { result = "parameter " + i + " of " + c .toString ( ) }
686-
687- override predicate hasLocationInfo ( string fp , int sl , int sc , int el , int ec ) {
688- c .hasLocationInfo ( fp , sl , sc , el , ec )
679+ this .getSummarizedCallable ( ) = call .asSummarizedCallable ( ) and this .getPos ( ) = idx
689680 }
690681 }
691682
@@ -1237,10 +1228,12 @@ module Public {
12371228private import Private
12381229private import Public
12391230
1240- class SummaryPostUpdateNode extends SummaryNode , PostUpdateNode {
1241- private Node pre ;
1231+ class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNode {
1232+ private FlowSummaryNode pre ;
12421233
1243- SummaryPostUpdateNode ( ) { FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , pre ) }
1234+ SummaryPostUpdateNode ( ) {
1235+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) , pre .getSummaryNode ( ) )
1236+ }
12441237
12451238 override Node getPreUpdateNode ( ) { result = pre }
12461239}
0 commit comments