C++: Simpler and more general approx. of constexpr

This commit is contained in:
Jonas Jensen
2019-01-24 15:06:54 +01:00
parent 7c44764aff
commit a383a1d6c9

View File

@@ -16,15 +16,8 @@ private predicate addressConstantVariable(Variable v) {
addressConstantExpression(v.getInitializer().getExpr().getFullyConverted()) and
// Here we should also require that `v` is constexpr, but we don't have that
// information in the db. See CPP-314. Instead, we require that the variable
// is not assigned to.
not exists(VariableAccess va | va.getTarget() = v |
// `v` may be assigned to, completely or partially
exists(Expr lvalue | variableAccessedAsValue(va, lvalue) |
lvalue = any(Assignment a).getLValue().getFullyConverted()
or
lvalue = any(CrementOperation c).getOperand().getFullyConverted()
)
)
// is never defined except in its initializer.
forall(Expr def | definition(v, def) | def = any(Initializer init).getExpr())
}
/**