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
5 changes: 3 additions & 2 deletions cpp/autosar/src/rules/A7-5-1/InvalidFunctionReturnType.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import cpp
import codingstandards.cpp.autosar
import semmle.code.cpp.dataflow.new.DataFlow

from Parameter p, ReturnStmt ret
from Parameter p, ReturnStmt ret, DataFlow::Node n
where
not isExcluded(p, FunctionsPackage::invalidFunctionReturnTypeQuery()) and
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()))
n.asParameter(0) = p and
DataFlow::localFlow(n, DataFlow::exprNode(ret.getExpr()))
Comment thread
MathiasVP marked this conversation as resolved.
Resolved
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 @@ -91,10 +91,10 @@ class StreamErrorStateCheck extends FunctionCall {
checkedArg = this.(StreamErrorStateCheckDirectCall).getACheckedStream()
or
// Or a wrapper around an existing `StreamErrorStateCheck`
exists(Function wrapper, int param, StreamErrorStateCheck wrappedErrorCheck |
exists(Function wrapper, int param, StreamErrorStateCheck wrappedErrorCheck, DataFlow::Node n |
getTarget() = wrapper and
DataFlow::localFlow(DataFlow::parameterNode(wrapper.getParameter(param)),
DataFlow::exprNode(wrappedErrorCheck.getACheckedStream())) and
n.asParameter(0) = wrapper.getParameter(param) and
DataFlow::localFlow(n, DataFlow::exprNode(wrappedErrorCheck.getACheckedStream())) and
checkedArg = getArgument(param)
)
}
Expand Down
Loading