Skip to content

Commit a383a1d

Browse files
committed
C++: Simpler and more general approx. of constexpr
1 parent 7c44764 commit a383a1d

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

cpp/ql/src/semmle/code/cpp/internal/AddressConstantExpression.qll

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ private predicate addressConstantVariable(Variable v) {
1616
addressConstantExpression(v.getInitializer().getExpr().getFullyConverted()) and
1717
// Here we should also require that `v` is constexpr, but we don't have that
1818
// information in the db. See CPP-314. Instead, we require that the variable
19-
// is not assigned to.
20-
not exists(VariableAccess va | va.getTarget() = v |
21-
// `v` may be assigned to, completely or partially
22-
exists(Expr lvalue | variableAccessedAsValue(va, lvalue) |
23-
lvalue = any(Assignment a).getLValue().getFullyConverted()
24-
or
25-
lvalue = any(CrementOperation c).getOperand().getFullyConverted()
26-
)
27-
)
19+
// is never defined except in its initializer.
20+
forall(Expr def | definition(v, def) | def = any(Initializer init).getExpr())
2821
}
2922

3023
/**

0 commit comments

Comments
 (0)