Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Comment thread
MathiasVP marked this conversation as resolved.
Resolved
| 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 | |
Expand Down
Loading