Skip to content

Commit b7df30e

Browse files
committed
Apply correct query format
1 parent 7361106 commit b7df30e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cpp/autosar/src/rules/A7-1-2/VariableMissingConstexpr.ql

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,28 @@ predicate isTypeZeroInitializable(Type t) {
3434
}
3535

3636
/*
37-
* Returns true if the given call may be evaluated at compile time and is compile time evaluated because
38-
* all its arguments are compile time evaluated and its default values are compile time evaluated.
39-
*/
37+
* Returns true if the given call may be evaluated at compile time and is compile time evaluated because
38+
* all its arguments are compile time evaluated and its default values are compile time evaluated.
39+
*/
40+
4041
predicate isCompileTimeEvaluated(Call call) {
4142
// 1. The call may be evaluated at compile time, because it is constexpr, and
4243
call.getTarget().isConstexpr() and
4344
// 2. all its arguments are compile time evaluated, and
44-
forall(DataFlow::Node ultimateArgSource | DataFlow::localFlow(ultimateArgSource, DataFlow::exprNode(call.getAnArgument())) and not DataFlow::localFlowStep(_, ultimateArgSource) |
45+
forall(DataFlow::Node ultimateArgSource |
46+
DataFlow::localFlow(ultimateArgSource, DataFlow::exprNode(call.getAnArgument())) and
47+
not DataFlow::localFlowStep(_, ultimateArgSource)
48+
|
4549
ultimateArgSource.asExpr() instanceof Literal
4650
or
4751
any(Call c | isCompileTimeEvaluated(c)) = ultimateArgSource.asExpr()
4852
) and
4953
// 3. all the default values used are compile time evaluated.
50-
forall(Expr defaultValue, Parameter parameterUsingDefaultValue, int idx | parameterUsingDefaultValue = call.getTarget().getParameter(idx) and not exists(call.getArgument(idx)) and parameterUsingDefaultValue.getAnAssignedValue() = defaultValue |
54+
forall(Expr defaultValue, Parameter parameterUsingDefaultValue, int idx |
55+
parameterUsingDefaultValue = call.getTarget().getParameter(idx) and
56+
not exists(call.getArgument(idx)) and
57+
parameterUsingDefaultValue.getAnAssignedValue() = defaultValue
58+
|
5159
defaultValue instanceof Literal
5260
or
5361
any(Call c | isCompileTimeEvaluated(c)) = defaultValue

0 commit comments

Comments
 (0)