mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user