Skip to content

M0-1-9: Fix dead-code false positive when constexpr integer is used in array size #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 19, 2024
Prev Previous commit
Next Next commit
Refactor get constexpr helper to public in unused variable qll and re…
…move from ql.
  • Loading branch information
fjatWbyT committed Sep 16, 2024
commit fb4e41896beb3ad77bb82d1cfd551cf0611eae73
6 changes: 0 additions & 6 deletions cpp/autosar/src/rules/M0-1-3/UnusedLocalVariable.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.deadcode.UnusedVariables

/** Gets the constant value of a constexpr/const variable. */
private string getConstExprValue(Variable v) {
result = v.getInitializer().getExpr().getValue() and
(v.isConst() or v.isConstexpr())
}

// This predicate is similar to getUseCount for M0-1-4 except that it also
// considers static_asserts. This was created to cater for M0-1-3 specifically
// and hence, doesn't attempt to reuse the M0-1-4 specific predicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ predicate maybeACompileTimeTemplateArgument(Variable v) {
}

/** Gets the constant value of a constexpr/const variable. */
private string getConstExprValue(Variable v) {
string getConstExprValue(Variable v) {
result = v.getInitializer().getExpr().getValue() and
(v.isConst() or v.isConstexpr())
}
Expand Down