@@ -23,15 +23,57 @@ class OptionalContentName extends string {
23
23
OptionalContentName ( ) { this instanceof ContentName or this = "" }
24
24
}
25
25
26
- /**
27
- * A description of a step on an inter-procedural data flow path.
28
- */
29
- private newtype TStepSummary =
30
- LevelStep ( ) or
31
- CallStep ( ) or
32
- ReturnStep ( ) or
33
- StoreStep ( ContentName content ) or
34
- LoadStep ( ContentName content )
26
+ cached
27
+ private module Cached {
28
+ /**
29
+ * A description of a step on an inter-procedural data flow path.
30
+ */
31
+ cached
32
+ newtype TStepSummary =
33
+ LevelStep ( ) or
34
+ CallStep ( ) or
35
+ ReturnStep ( ) or
36
+ StoreStep ( ContentName content ) or
37
+ LoadStep ( ContentName content )
38
+
39
+ /** Gets the summary resulting from appending `step` to type-tracking summary `tt`. */
40
+ cached
41
+ TypeTracker append ( TypeTracker tt , StepSummary step ) {
42
+ exists ( Boolean hasCall , OptionalContentName content | tt = MkTypeTracker ( hasCall , content ) |
43
+ step = LevelStep ( ) and result = tt
44
+ or
45
+ step = CallStep ( ) and result = MkTypeTracker ( true , content )
46
+ or
47
+ step = ReturnStep ( ) and hasCall = false and result = tt
48
+ or
49
+ step = LoadStep ( content ) and result = MkTypeTracker ( hasCall , "" )
50
+ or
51
+ exists ( string p | step = StoreStep ( p ) and content = "" and result = MkTypeTracker ( hasCall , p ) )
52
+ )
53
+ }
54
+
55
+ /**
56
+ * Gets the summary that corresponds to having taken a forwards
57
+ * heap and/or intra-procedural step from `nodeFrom` to `nodeTo`.
58
+ *
59
+ * Steps contained in this predicate should _not_ depend on the call graph.
60
+ */
61
+ cached
62
+ predicate stepNoCall ( LocalSourceNode nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
63
+ exists ( Node mid | nodeFrom .flowsTo ( mid ) and smallstepNoCall ( mid , nodeTo , summary ) )
64
+ }
65
+
66
+ /**
67
+ * Gets the summary that corresponds to having taken a forwards
68
+ * inter-procedural step from `nodeFrom` to `nodeTo`.
69
+ */
70
+ cached
71
+ predicate stepCall ( LocalSourceNode nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
72
+ exists ( Node mid | nodeFrom .flowsTo ( mid ) and smallstepCall ( mid , nodeTo , summary ) )
73
+ }
74
+ }
75
+
76
+ private import Cached
35
77
36
78
/**
37
79
* INTERNAL: Use `TypeTracker` or `TypeBackTracker` instead.
@@ -53,28 +95,29 @@ class StepSummary extends TStepSummary {
53
95
}
54
96
}
55
97
56
- /** Provides predicates for updating step summaries (`StepSummary`s). */
57
- module StepSummary {
58
- /**
59
- * Gets the summary that corresponds to having taken a forwards
60
- * heap and/or intra-procedural step from `nodeFrom` to `nodeTo`.
61
- *
62
- * Steps contained in this predicate should _not_ depend on the call graph.
63
- */
64
- cached
65
- private predicate stepNoCall ( LocalSourceNode nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
66
- exists ( Node mid | nodeFrom . flowsTo ( mid ) and smallstepNoCall ( mid , nodeTo , summary ) )
67
- }
98
+ pragma [ noinline ]
99
+ private predicate smallstepNoCall ( Node nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
100
+ jumpStep ( nodeFrom , nodeTo ) and
101
+ summary = LevelStep ( )
102
+ or
103
+ exists ( string content |
104
+ StepSummary :: localSourceStoreStep ( nodeFrom , nodeTo , content ) and
105
+ summary = StoreStep ( content )
106
+ or
107
+ basicLoadStep ( nodeFrom , nodeTo , content ) and summary = LoadStep ( content )
108
+ )
109
+ }
68
110
69
- /**
70
- * Gets the summary that corresponds to having taken a forwards
71
- * inter-procedural step from `nodeFrom` to `nodeTo`.
72
- */
73
- cached
74
- private predicate stepCall ( LocalSourceNode nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
75
- exists ( Node mid | nodeFrom .flowsTo ( mid ) and smallstepCall ( mid , nodeTo , summary ) )
76
- }
111
+ pragma [ noinline]
112
+ private predicate smallstepCall ( Node nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
113
+ callStep ( nodeFrom , nodeTo ) and summary = CallStep ( )
114
+ or
115
+ returnStep ( nodeFrom , nodeTo ) and
116
+ summary = ReturnStep ( )
117
+ }
77
118
119
+ /** Provides predicates for updating step summaries (`StepSummary`s). */
120
+ module StepSummary {
78
121
/**
79
122
* Gets the summary that corresponds to having taken a forwards
80
123
* heap and/or inter-procedural step from `nodeFrom` to `nodeTo`.
@@ -92,27 +135,6 @@ module StepSummary {
92
135
stepCall ( nodeFrom , nodeTo , summary )
93
136
}
94
137
95
- pragma [ noinline]
96
- private predicate smallstepNoCall ( Node nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
97
- jumpStep ( nodeFrom , nodeTo ) and
98
- summary = LevelStep ( )
99
- or
100
- exists ( string content |
101
- localSourceStoreStep ( nodeFrom , nodeTo , content ) and
102
- summary = StoreStep ( content )
103
- or
104
- basicLoadStep ( nodeFrom , nodeTo , content ) and summary = LoadStep ( content )
105
- )
106
- }
107
-
108
- pragma [ noinline]
109
- private predicate smallstepCall ( Node nodeFrom , LocalSourceNode nodeTo , StepSummary summary ) {
110
- callStep ( nodeFrom , nodeTo ) and summary = CallStep ( )
111
- or
112
- returnStep ( nodeFrom , nodeTo ) and
113
- summary = ReturnStep ( )
114
- }
115
-
116
138
/**
117
139
* Gets the summary that corresponds to having taken a forwards
118
140
* local, heap and/or inter-procedural step from `nodeFrom` to `nodeTo`.
@@ -193,18 +215,7 @@ class TypeTracker extends TTypeTracker {
193
215
TypeTracker ( ) { this = MkTypeTracker ( hasCall , content ) }
194
216
195
217
/** Gets the summary resulting from appending `step` to this type-tracking summary. */
196
- cached
197
- TypeTracker append ( StepSummary step ) {
198
- step = LevelStep ( ) and result = this
199
- or
200
- step = CallStep ( ) and result = MkTypeTracker ( true , content )
201
- or
202
- step = ReturnStep ( ) and hasCall = false and result = this
203
- or
204
- step = LoadStep ( content ) and result = MkTypeTracker ( hasCall , "" )
205
- or
206
- exists ( string p | step = StoreStep ( p ) and content = "" and result = MkTypeTracker ( hasCall , p ) )
207
- }
218
+ TypeTracker append ( StepSummary step ) { result = append ( this , step ) }
208
219
209
220
/** Gets a textual representation of this summary. */
210
221
string toString ( ) {
0 commit comments