Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.SideEffect
import codingstandards.cpp.sideeffect.DefaultEffects
import codingstandards.cpp.Expr

from BinaryLogicalOperation op, Expr rhs
where
not isExcluded(op,
SideEffects1Package::rightHandOperandOfALogicalAndOperatorsContainSideEffectsQuery()) and
rhs = op.getRightOperand() and
hasSideEffect(rhs) and
not rhs.(NoExceptExpr).getExpr().isUnevaluated() and
not rhs.(SizeofExprOperator).getExprOperand().isUnevaluated()
not rhs instanceof UnevaluatedExprExtension
select op, "The $@ may have a side effect that is not always evaluated.", rhs, "right-hand operand"
14 changes: 14 additions & 0 deletions cpp/common/src/codingstandards/cpp/Expr.qll
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,17 @@ module MisraExpr {
CValue() { isCValue(this) }
}
}

/**
* an operator that does not evaluate its operand
*/
class UnevaluatedExprExtension extends Expr {
UnevaluatedExprExtension() {
this.getChild(_).isUnevaluated()
Comment thread
knewbury01 marked this conversation as resolved.
Outdated
or
exists(FunctionCall declval |
declval.getTarget().hasQualifiedName("std", "declval") and
declval.getAChild() = this
)
}
}