@@ -12,33 +12,47 @@ private module Cached {
12
12
LevelStep ( ) or
13
13
CallStep ( ) or
14
14
ReturnStep ( ) or
15
- StoreStep ( TypeTrackerContent content ) or
16
- LoadStep ( TypeTrackerContent content ) or
15
+ StoreStep ( TypeTrackerContentSet contents ) or
16
+ LoadStep ( TypeTrackerContentSet contents ) or
17
17
JumpStep ( )
18
18
19
+ pragma [ nomagic]
20
+ private TypeTracker noContentTypeTracker ( boolean hasCall ) {
21
+ result = MkTypeTracker ( hasCall , noContent ( ) )
22
+ }
23
+
19
24
/** Gets the summary resulting from appending `step` to type-tracking summary `tt`. */
20
25
cached
21
26
TypeTracker append ( TypeTracker tt , StepSummary step ) {
22
- exists ( Boolean hasCall , OptionalTypeTrackerContent content |
23
- tt = MkTypeTracker ( hasCall , content )
27
+ exists ( Boolean hasCall , OptionalTypeTrackerContent currentContent |
28
+ tt = MkTypeTracker ( hasCall , currentContent )
24
29
|
25
30
step = LevelStep ( ) and result = tt
26
31
or
27
- step = CallStep ( ) and result = MkTypeTracker ( true , content )
32
+ step = CallStep ( ) and result = MkTypeTracker ( true , currentContent )
28
33
or
29
34
step = ReturnStep ( ) and hasCall = false and result = tt
30
35
or
31
- step = LoadStep ( content ) and result = MkTypeTracker ( hasCall , noContent ( ) )
32
- or
33
- exists ( TypeTrackerContent p |
34
- step = StoreStep ( p ) and content = noContent ( ) and result = MkTypeTracker ( hasCall , p )
35
- )
36
- or
37
36
step = JumpStep ( ) and
38
- result = MkTypeTracker ( false , content )
37
+ result = MkTypeTracker ( false , currentContent )
38
+ )
39
+ or
40
+ exists ( TypeTrackerContentSet contents , boolean hasCall |
41
+ step = LoadStep ( pragma [ only_bind_into ] ( contents ) ) and
42
+ tt = MkTypeTracker ( hasCall , contents .getAReadContent ( ) ) and
43
+ result = noContentTypeTracker ( hasCall )
44
+ or
45
+ step = StoreStep ( pragma [ only_bind_into ] ( contents ) ) and
46
+ tt = noContentTypeTracker ( hasCall ) and
47
+ result = MkTypeTracker ( hasCall , contents .getAStoreContent ( ) )
39
48
)
40
49
}
41
50
51
+ pragma [ nomagic]
52
+ private TypeBackTracker noContentTypeBackTracker ( boolean hasReturn ) {
53
+ result = MkTypeBackTracker ( hasReturn , noContent ( ) )
54
+ }
55
+
42
56
/** Gets the summary resulting from prepending `step` to this type-tracking summary. */
43
57
cached
44
58
TypeBackTracker prepend ( TypeBackTracker tbt , StepSummary step ) {
@@ -51,15 +65,19 @@ private module Cached {
51
65
or
52
66
step = ReturnStep ( ) and result = MkTypeBackTracker ( true , content )
53
67
or
54
- exists ( TypeTrackerContent p |
55
- step = LoadStep ( p ) and content = noContent ( ) and result = MkTypeBackTracker ( hasReturn , p )
56
- )
57
- or
58
- step = StoreStep ( content ) and result = MkTypeBackTracker ( hasReturn , noContent ( ) )
59
- or
60
68
step = JumpStep ( ) and
61
69
result = MkTypeBackTracker ( false , content )
62
70
)
71
+ or
72
+ exists ( TypeTrackerContentSet contents , boolean hasReturn |
73
+ step = StoreStep ( pragma [ only_bind_into ] ( contents ) ) and
74
+ tbt = MkTypeBackTracker ( hasReturn , contents .getAReadContent ( ) ) and
75
+ result = noContentTypeBackTracker ( hasReturn )
76
+ or
77
+ step = LoadStep ( pragma [ only_bind_into ] ( contents ) ) and
78
+ tbt = noContentTypeBackTracker ( hasReturn ) and
79
+ result = MkTypeBackTracker ( hasReturn , contents .getAStoreContent ( ) )
80
+ )
63
81
}
64
82
65
83
/**
@@ -99,9 +117,11 @@ class StepSummary extends TStepSummary {
99
117
or
100
118
this instanceof ReturnStep and result = "return"
101
119
or
102
- exists ( TypeTrackerContent content | this = StoreStep ( content ) | result = "store " + content )
120
+ exists ( TypeTrackerContentSet contents | this = StoreStep ( contents ) |
121
+ result = "store " + contents
122
+ )
103
123
or
104
- exists ( TypeTrackerContent content | this = LoadStep ( content ) | result = "load " + content )
124
+ exists ( TypeTrackerContentSet contents | this = LoadStep ( contents ) | result = "load " + contents )
105
125
or
106
126
this instanceof JumpStep and result = "jump"
107
127
}
@@ -115,11 +135,11 @@ private predicate smallstepNoCall(Node nodeFrom, TypeTrackingNode nodeTo, StepSu
115
135
levelStep ( nodeFrom , nodeTo ) and
116
136
summary = LevelStep ( )
117
137
or
118
- exists ( TypeTrackerContent content |
119
- StepSummary:: localSourceStoreStep ( nodeFrom , nodeTo , content ) and
120
- summary = StoreStep ( content )
138
+ exists ( TypeTrackerContentSet contents |
139
+ StepSummary:: localSourceStoreStep ( nodeFrom , nodeTo , contents ) and
140
+ summary = StoreStep ( contents )
121
141
or
122
- basicLoadStep ( nodeFrom , nodeTo , content ) and summary = LoadStep ( content )
142
+ basicLoadStep ( nodeFrom , nodeTo , contents ) and summary = LoadStep ( contents )
123
143
)
124
144
}
125
145
@@ -189,8 +209,10 @@ module StepSummary {
189
209
* function. This means we will track the fact that `x.attr` can have the type of `y` into the
190
210
* assignment to `z` inside `bar`, even though this attribute write happens _after_ `bar` is called.
191
211
*/
192
- predicate localSourceStoreStep ( Node nodeFrom , TypeTrackingNode nodeTo , TypeTrackerContent content ) {
193
- exists ( Node obj | nodeTo .flowsTo ( obj ) and basicStoreStep ( nodeFrom , obj , content ) )
212
+ predicate localSourceStoreStep (
213
+ Node nodeFrom , TypeTrackingNode nodeTo , TypeTrackerContentSet contents
214
+ ) {
215
+ exists ( Node obj | nodeTo .flowsTo ( obj ) and basicStoreStep ( nodeFrom , obj , contents ) )
194
216
}
195
217
}
196
218
0 commit comments