Skip to content

Commit 6d91ebe

Browse files
committed
C++: Simplify 'getSourceDataFlowNode' for parameters.
1 parent b34e1cc commit 6d91ebe

5 files changed

Lines changed: 202 additions & 133 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,14 @@ private module Input2 implements Impl::Private::InputSig2 {
247247
r.getKind() = rk
248248
}
249249

250+
pragma[nomagic]
251+
private predicate hasParameterAndIndirectionIndex(
252+
Parameter p, int indirectionIndex, ParameterNode n
253+
) {
254+
n.getParameter() = p and
255+
n.getIndirectionIndex() = indirectionIndex
256+
}
257+
250258
bindingset[e, sc]
251259
Node getSourceDataFlowNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) {
252260
exists(DataFlowCall call |
@@ -272,10 +280,9 @@ private module Input2 implements Impl::Private::InputSig2 {
272280
)
273281
)
274282
or
275-
exists(ParameterPosition pos, ParameterNode p |
283+
exists(ParameterPosition pos |
276284
sc = Impl::Private::SummaryComponent::parameter(pos) and
277-
p.isParameterOf(e.getEnclosingCallable(), pos) and
278-
result = p
285+
hasParameterAndIndirectionIndex(e, pos.getIndirectionIndex(), result)
279286
)
280287
or
281288
exists(Function f, ReturnKind rk |

0 commit comments

Comments
 (0)