C++: Use isConstexpr instead of workaround

The `addressConstantVariable` predicate was the slowest single predicate
when running the full LGTM suite on Chromium. Fortunately it's only
executed once, but it could be easily made faster by using the new
`Variable.isConstexpr` predicate instead of the slow workaround that was
in its place.
This commit is contained in:
Jonas Jensen
2019-05-15 14:35:21 +02:00
parent 8b012b2cab
commit f38253da89

View File

@@ -13,10 +13,7 @@ predicate addressConstantExpression(Expr e) {
/** Holds if `v` is a constexpr variable initialized to a constant address. */
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 never defined except in its initializer.
forall(Expr def | definition(v, def) | def = any(Initializer init).getExpr())
v.isConstexpr()
}
/**