Skip to content

Commit 887cc8d

Browse files
committed
C++: Select the indirect node for the sink in 'cpp/autosar/invalid-function-return-type'.
1 parent a32f4a5 commit 887cc8d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ where
2424
p.getUnderlyingType().isDeeplyConst() and
2525
p.getType() instanceof DerivedType and
2626
p.getFunction().getType().stripTopLevelSpecifiers() instanceof DerivedType and
27-
DataFlow::localFlow(DataFlow::parameterNode(p), DataFlow::exprNode(ret.getExpr()))
27+
// `parameterNode` on a reference parameter gives back the node representing the indirection of the
28+
// reference, so we pick the indirect node for the return expression.
29+
DataFlow::localFlow(DataFlow::parameterNode(p), DataFlow::indirectExprNode(ret.getExpr()))
2830
select ret,
2931
"Function " + p.getFunction().getName() +
3032
" returns a reference or a pointer to $@ that is passed by reference to const.", p, "parameter"

0 commit comments

Comments
 (0)