Skip to content

Commit d9bf0a6

Browse files
committed
Data flow: Address review comments
1 parent b6206d7 commit d9bf0a6

File tree

17 files changed

+1084
-1100
lines changed

17 files changed

+1084
-1100
lines changed

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

Lines changed: 74 additions & 76 deletions
Large diffs are not rendered by default.

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

Lines changed: 74 additions & 76 deletions
Large diffs are not rendered by default.

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

Lines changed: 74 additions & 76 deletions
Large diffs are not rendered by default.

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

Lines changed: 74 additions & 76 deletions
Large diffs are not rendered by default.

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
private import DataFlowImplSpecific::Private
22
import DataFlowImplSpecific::Public
33

4+
private ReturnNode getAReturnNodeOfKind(ReturnKind kind) { result.getKind() = kind }
5+
46
cached
57
private module ImplCommon {
68
/**
@@ -83,7 +85,7 @@ private module ImplCommon {
8385
DataFlowCall call, int i, ArgumentNode arg, DataFlowCallable enclosing
8486
) {
8587
arg.argumentOf(call, i) and
86-
argumentValueFlowsThroughNoCtx0(call, arg, _) and
88+
argumentValueFlowsThroughNoCtx(arg, _) and
8789
enclosing = arg.getEnclosingCallable()
8890
}
8991

@@ -94,7 +96,9 @@ private module ImplCommon {
9496
or
9597
exists(ParameterNode p | outercc = TSomeCall(p, _) | c = p.getEnclosingCallable())
9698
or
97-
exists(DataFlowCall other | outercc = TSpecificCall(other, _, _) | c = viableCallable(other))
99+
exists(DataFlowCall other | outercc = TSpecificCall(other, _, _) |
100+
reducedViableImplInCallContext(_, c, other)
101+
)
98102
)
99103
}
100104

@@ -124,12 +128,13 @@ private module ImplCommon {
124128
)
125129
}
126130

127-
cached
128-
CallContextCall getAValidCallContextForParameter(ParameterNode p) {
131+
private CallContextCall getAValidCallContextForParameter(ParameterNode p) {
129132
result = TSomeCall(p, _)
130133
or
131-
exists(DataFlowCall call, int i | result = TSpecificCall(call, i, _) |
132-
p.isParameterOf(_, i) and p.getEnclosingCallable() = viableCallable(call)
134+
exists(DataFlowCall call, int i, DataFlowCallable callable |
135+
result = TSpecificCall(call, i, _) and
136+
p.isParameterOf(callable, i) and
137+
reducedViableImplInCallContext(_, callable, call)
133138
)
134139
}
135140

@@ -156,8 +161,6 @@ private module ImplCommon {
156161
)
157162
}
158163

159-
private ReturnNode getAReturnNodeOfKind(ReturnKind kind) { result.getKind() = kind }
160-
161164
/**
162165
* Holds if `p` can flow to a return node of kind `kind` in the same
163166
* callable using only value-preserving steps, in call context `cc`.
@@ -172,8 +175,7 @@ private module ImplCommon {
172175
DataFlowCall call, ArgumentNode arg, ReturnKind kind, CallContext cc
173176
) {
174177
exists(ParameterNode param, CallContext innercc |
175-
viableParamArg(call, param, arg, cc, innercc)
176-
|
178+
viableParamArg(call, param, arg, cc, innercc) and
177179
parameterValueFlowsThrough(param, kind, innercc)
178180
)
179181
}
@@ -271,7 +273,8 @@ private module ImplCommon {
271273
}
272274

273275
private predicate storeReturn(Node node1, Content f, Node node2) {
274-
exists(DataFlowCall call, ReturnKind kind | storeReturn0(call, kind, node1, f) |
276+
exists(DataFlowCall call, ReturnKind kind |
277+
storeReturn0(call, kind, node1, f) and
275278
node2 = getAnOutNode(call, kind) and
276279
compatibleTypes(node1.getTypeBound(), f.getType()) and
277280
compatibleTypes(node2.getTypeBound(), f.getContainerType())
@@ -302,7 +305,8 @@ private module ImplCommon {
302305
predicate read(Node node1, Content f, Node node2) {
303306
readStep(node1, f, node2) and storeStep(_, f, _)
304307
or
305-
exists(DataFlowCall call, ReturnKind kind | read0(call, kind, node1, f) |
308+
exists(DataFlowCall call, ReturnKind kind |
309+
read0(call, kind, node1, f) and
306310
node2 = getAnOutNode(call, kind) and
307311
compatibleTypes(node1.getTypeBound(), f.getContainerType()) and
308312
compatibleTypes(node2.getTypeBound(), f.getType())

0 commit comments

Comments
 (0)