Skip to content

Commit f38253d

Browse files
committed
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.
1 parent 8b012b2 commit f38253d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ predicate addressConstantExpression(Expr e) {
1313
/** Holds if `v` is a constexpr variable initialized to a constant address. */
1414
private predicate addressConstantVariable(Variable v) {
1515
addressConstantExpression(v.getInitializer().getExpr().getFullyConverted()) and
16-
// Here we should also require that `v` is constexpr, but we don't have that
17-
// information in the db. See CPP-314. Instead, we require that the variable
18-
// is never defined except in its initializer.
19-
forall(Expr def | definition(v, def) | def = any(Initializer init).getExpr())
16+
v.isConstexpr()
2017
}
2118

2219
/**

0 commit comments

Comments
 (0)