Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f341aa7

Browse files
committed
Java/C: Sync dataflow copies.
1 parent 3cdcbf0 commit f341aa7

10 files changed

Lines changed: 13496 additions & 12343 deletions

File tree

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 1496 additions & 1369 deletions
Large diffs are not rendered by default.

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import DataFlowUtil
32
private import DataFlowPrivate
43
private import DataFlowDispatch
@@ -55,9 +54,7 @@ private module ImplCommon {
5554
*/
5655
cached
5756
predicate parameterValueFlowsThrough(ParameterNode p) {
58-
exists(ReturnNode ret |
59-
parameterValueFlow(p, ret)
60-
)
57+
exists(ReturnNode ret | parameterValueFlow(p, ret))
6158
}
6259

6360
/**
@@ -112,8 +109,10 @@ private module ImplCommon {
112109
storeViaSideEffect(node1, f, node2) or
113110
storeReturn(node1, f, node2)
114111
}
112+
115113
private predicate storeViaSideEffect(Node node1, Content f, PostUpdateNode node2) {
116-
storeStep(node1, f, node2) and readStep(_, f, _) or
114+
storeStep(node1, f, node2) and readStep(_, f, _)
115+
or
117116
exists(Call call, int i1, int i2 |
118117
setterCall(call, i1, i2, f) and
119118
node1.(ArgumentNode).argumentOf(call, i1) and
@@ -122,6 +121,7 @@ private module ImplCommon {
122121
compatibleTypes(node2.getTypeBound(), f.getDeclaringType())
123122
)
124123
}
124+
125125
pragma[nomagic]
126126
private predicate setterInParam(ParameterNode p1, Content f, ParameterNode p2) {
127127
exists(Node n1, PostUpdateNode n2 |
@@ -131,6 +131,7 @@ private module ImplCommon {
131131
p1 != p2
132132
)
133133
}
134+
134135
pragma[nomagic]
135136
private predicate setterCall(Call call, int i1, int i2, Content f) {
136137
exists(Callable callable, ParameterNode p1, ParameterNode p2 |
@@ -140,6 +141,7 @@ private module ImplCommon {
140141
p2.isParameterOf(callable, i2)
141142
)
142143
}
144+
143145
private predicate storeReturn(Node node1, Content f, Node node2) {
144146
exists(ParameterNode p, ArgumentNode arg |
145147
arg = node1 and
@@ -150,6 +152,7 @@ private module ImplCommon {
150152
compatibleTypes(node2.getTypeBound(), f.getDeclaringType())
151153
)
152154
}
155+
153156
private predicate setterReturn(ParameterNode p, Content f) {
154157
exists(Node n1, Node n2, ReturnNode ret |
155158
parameterValueFlow(p, n1) and
@@ -164,7 +167,8 @@ private module ImplCommon {
164167
*/
165168
cached
166169
predicate read(Node node1, Content f, Node node2) {
167-
readStep(node1, f, node2) and storeStep(_, f, _) or
170+
readStep(node1, f, node2) and storeStep(_, f, _)
171+
or
168172
exists(ParameterNode p, ArgumentNode arg |
169173
arg = node1 and
170174
viableParamArg(p, arg) and
@@ -174,6 +178,7 @@ private module ImplCommon {
174178
compatibleTypes(node2.getTypeBound(), f.getType())
175179
)
176180
}
181+
177182
private predicate getter(ParameterNode p, Content f) {
178183
exists(Node n1, Node n2, ReturnNode ret |
179184
parameterValueFlow(p, n1) and
@@ -196,9 +201,7 @@ private module ImplCommon {
196201
* expression that reaches a `this` parameter.
197202
*/
198203
private predicate callHasInstanceArgument(Call call) {
199-
exists(ArgumentNode arg |
200-
arg.argumentOf(call, -1)
201-
)
204+
exists(ArgumentNode arg | arg.argumentOf(call, -1))
202205
}
203206

204207
cached
@@ -207,9 +210,11 @@ private module ImplCommon {
207210
TSpecificCall(Call call, int i, boolean emptyAp) {
208211
reducedViableImplInCallContext(_, _, call) and
209212
(emptyAp = true or emptyAp = false) and
210-
(exists(call.getArgument(i))
211-
or
212-
i = -1 and callHasInstanceArgument(call))
213+
(
214+
exists(call.getArgument(i))
215+
or
216+
i = -1 and callHasInstanceArgument(call)
217+
)
213218
} or
214219
TSomeCall(ParameterNode p, boolean emptyAp) { emptyAp = true or emptyAp = false } or
215220
TReturn(Method m, MethodAccess ma) { reducedViableImplInReturn(m, ma) }
@@ -232,19 +237,22 @@ import ImplCommon
232237
* this dispatch target of `ma` implies a reduced set of dispatch origins
233238
* to which data may flow if it should reach a `return` statement.
234239
*/
235-
abstract class CallContext extends TCallContext {
236-
abstract string toString();
237-
}
240+
abstract class CallContext extends TCallContext { abstract string toString(); }
241+
238242
class CallContextAny extends CallContext, TAnyCallContext {
239243
override string toString() { result = "CcAny" }
240244
}
245+
241246
abstract class CallContextCall extends CallContext { }
247+
242248
class CallContextSpecificCall extends CallContextCall, TSpecificCall {
243249
override string toString() { result = "CcCall" }
244250
}
251+
245252
class CallContextSomeCall extends CallContextCall, TSomeCall {
246253
override string toString() { result = "CcSomeCall" }
247254
}
255+
248256
class CallContextReturn extends CallContext, TReturn {
249257
override string toString() { result = "CcReturn" }
250258
}
@@ -263,12 +271,14 @@ predicate resolveReturn(CallContext cc, Callable callable, Call call) {
263271
bindingset[call, cc]
264272
Callable resolveCall(Call call, CallContext cc) {
265273
exists(Call ctx | cc = TSpecificCall(ctx, _, _) |
266-
if reducedViableImplInCallContext(call, _, ctx) then
267-
result = prunedViableImplInCallContext(call, ctx)
268-
else
269-
result = viableCallable(call)
270-
) or
271-
result = viableCallable(call) and cc instanceof CallContextSomeCall or
272-
result = viableCallable(call) and cc instanceof CallContextAny or
274+
if reducedViableImplInCallContext(call, _, ctx)
275+
then result = prunedViableImplInCallContext(call, ctx)
276+
else result = viableCallable(call)
277+
)
278+
or
279+
result = viableCallable(call) and cc instanceof CallContextSomeCall
280+
or
281+
result = viableCallable(call) and cc instanceof CallContextAny
282+
or
273283
result = viableCallable(call) and cc instanceof CallContextReturn
274284
}

0 commit comments

Comments
 (0)