diff --git a/cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql b/cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql index 6b94c68cff..cbcc59d0f4 100644 --- a/cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql +++ b/cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql @@ -24,7 +24,9 @@ where p.getUnderlyingType().isDeeplyConst() and p.getType() instanceof DerivedType and p.getFunction().getType().stripTopLevelSpecifiers() instanceof DerivedType and - DataFlow::localFlow(DataFlow::parameterNode(p), DataFlow::exprNode(ret.getExpr())) + // `parameterNode` on a reference parameter gives back the node representing the indirection of the + // reference, so we pick the indirect node for the return expression. + DataFlow::localFlow(DataFlow::parameterNode(p), DataFlow::indirectExprNode(ret.getExpr())) select ret, "Function " + p.getFunction().getName() + " returns a reference or a pointer to $@ that is passed by reference to const.", p, "parameter" diff --git a/cpp/common/test/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.expected b/cpp/common/test/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.expected index 00f3128a8b..2e1a77ec93 100644 --- a/cpp/common/test/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.expected +++ b/cpp/common/test/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.expected @@ -21,6 +21,8 @@ edges | test.cpp:5:24:5:25 | call to shared_ptr | test.cpp:6:28:6:29 | p1 | provenance | | | test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | Config | | test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | Config | +| test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | TaintFunction | +| test.cpp:5:27:5:28 | v1 | test.cpp:5:24:5:25 | call to shared_ptr | provenance | TaintFunction | | test.cpp:6:28:6:29 | p1 | test.cpp:6:31:6:33 | call to get | provenance | Config | | test.cpp:6:28:6:29 | p1 | test.cpp:6:31:6:33 | call to get | provenance | Config | | test.cpp:8:3:8:14 | ... = ... | test.cpp:9:28:9:29 | v2 | provenance | |