From ad80b36074bb41ece2b7fba1435449fc7ed97c41 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Fri, 24 Jan 2025 20:16:04 +0000 Subject: [PATCH] C++: Don't generate parameter nodes for bodyless parameters when there is a summary of the enclosing function. --- .../semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll | 2 +- .../lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll | 1 + .../dataflow/dataflow-tests/dataflow-ir-consistency.expected | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll index 40740d956dc..dc4761696d3 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll @@ -1011,7 +1011,7 @@ class CastNode extends Node { } cached -private newtype TDataFlowCallable = +newtype TDataFlowCallable = TSourceCallable(Cpp::Declaration decl) { not decl instanceof FlowSummaryImpl::Public::SummarizedCallable } or diff --git a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll index 8b01aa645aa..be91f96e351 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll @@ -66,6 +66,7 @@ private newtype TIRDataFlowNode = TFinalGlobalValue(Ssa::GlobalUse globalUse) or TInitialGlobalValue(Ssa::GlobalDef globalUse) or TBodyLessParameterNodeImpl(Parameter p, int indirectionIndex) { + not exists(TSummarizedCallable(p.getFunction())) and // Rule out parameters of catch blocks. not exists(p.getCatchBlock()) and // We subtract one because `getMaxIndirectionsForType` returns the maximum diff --git a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected index fa3f344f383..d0d49db4a21 100644 --- a/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected +++ b/cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected @@ -32,8 +32,6 @@ postWithInFlow | test.cpp:1077:10:1077:11 | swap output argument | PostUpdateNode should not be the target of local flow. | viableImplInCallContextTooLarge uniqueParameterNodeAtPosition -| ../../../include/iterator.h:22:3:22:10 | iterator | *0 | ../../../include/iterator.h:22:3:22:10 | [summary param] *0 in iterator | Parameters with overlapping positions. | -| ../../../include/iterator.h:22:3:22:10 | iterator | *0 | ../../../include/iterator.h:22:67:22:71 | *other | Parameters with overlapping positions. | uniqueParameterNodePosition uniqueContentApprox identityLocalStep