@@ -11,12 +11,7 @@ private newtype TNode =
11
11
MkSsaNode ( SsaDefinition ssa ) or
12
12
MkGlobalFunctionNode ( Function f ) or
13
13
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 )
20
15
21
16
/** Nodes intended for only use inside the data-flow libraries. */
22
17
module Private {
@@ -30,9 +25,7 @@ module Private {
30
25
not exists ( n .getEnclosingCallable ( ) ) and
31
26
result .asFileScope ( ) = n .getFile ( )
32
27
or
33
- n = MkSummarizedParameterNode ( result .asSummarizedCallable ( ) , _)
34
- or
35
- n = MkSummaryInternalNode ( result .asSummarizedCallable ( ) , _)
28
+ result .asSummarizedCallable ( ) = n .( FlowSummaryNode ) .getSummarizedCallable ( )
36
29
}
37
30
38
31
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
@@ -52,7 +45,7 @@ module Private {
52
45
ReturnNode ( ) {
53
46
this .( Public:: ResultNode ) .getIndex ( ) = kind .getIndex ( )
54
47
or
55
- this .( SummaryNode ) .isReturn ( kind )
48
+ this .( FlowSummaryNode ) .isReturn ( kind )
56
49
}
57
50
58
51
/** Gets the kind of this returned value. */
@@ -72,33 +65,33 @@ module Private {
72
65
/**
73
66
* A data-flow node used to model flow summaries.
74
67
*/
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 ) }
78
70
79
- SummaryNode ( ) { this = MkSummaryInternalNode ( c , state ) }
71
+ SummarizedCallable getSummarizedCallable ( ) {
72
+ result = this .getSummaryNode ( ) .getSummarizedCallable ( )
73
+ }
80
74
81
75
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 )
83
77
}
84
78
85
- override string toString ( ) { result = "[summary] " + state + " in " + c }
79
+ override string toString ( ) { result = this . getSummaryNode ( ) . toString ( ) }
86
80
87
81
/** Holds if this summary node is the `i`th argument of `call`. */
88
82
predicate isArgumentOf ( DataFlowCall call , int i ) {
89
- FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this , i )
83
+ FlowSummaryImpl:: Private:: summaryArgumentNode ( call , this . getSummaryNode ( ) , i )
90
84
}
91
85
92
86
/** 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
+ }
94
90
95
91
/** 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
+ }
102
95
}
103
96
}
104
97
@@ -661,31 +654,29 @@ module Public {
661
654
* A summary node which represents a parameter in a function which doesn't
662
655
* already have a parameter nodes.
663
656
*/
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
+ }
667
661
668
- SummarizedParameterNode ( ) { this = MkSummarizedParameterNode ( c , i ) }
662
+ private int getPos ( ) {
663
+ FlowSummaryImpl:: Private:: summaryParameterNode ( this .getSummaryNode ( ) , result )
664
+ }
669
665
670
666
// There are no AST representations of summarized parameter nodes
671
667
override ControlFlow:: Root getRoot ( ) { none ( ) }
672
668
673
669
override string getNodeKind ( ) { result = "external parameter node" }
674
670
675
671
override Type getType ( ) {
676
- result = c . getType ( ) .getParameterType ( i )
672
+ result = this . getSummarizedCallable ( ) . getType ( ) .getParameterType ( this . getPos ( ) )
677
673
or
678
- i = - 1 and result = c .asFunction ( ) .( Method ) .getReceiverType ( )
674
+ this .getPos ( ) = - 1 and
675
+ result = this .getSummarizedCallable ( ) .asFunction ( ) .( Method ) .getReceiverType ( )
679
676
}
680
677
681
678
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
689
680
}
690
681
}
691
682
@@ -1237,10 +1228,12 @@ module Public {
1237
1228
private import Private
1238
1229
private import Public
1239
1230
1240
- class SummaryPostUpdateNode extends SummaryNode , PostUpdateNode {
1241
- private Node pre ;
1231
+ class SummaryPostUpdateNode extends FlowSummaryNode , PostUpdateNode {
1232
+ private FlowSummaryNode pre ;
1242
1233
1243
- SummaryPostUpdateNode ( ) { FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this , pre ) }
1234
+ SummaryPostUpdateNode ( ) {
1235
+ FlowSummaryImpl:: Private:: summaryPostUpdateNode ( this .getSummaryNode ( ) , pre .getSummaryNode ( ) )
1236
+ }
1244
1237
1245
1238
override Node getPreUpdateNode ( ) { result = pre }
1246
1239
}
0 commit comments