Merge pull request #1326 from jbj/addressConstantVariable-isConstexpr

C++: Use isConstexpr instead of workaround in AddressConstantExpr
This commit is contained in:
Robert Marsh
2019-05-16 15:18:56 -07:00
committed by GitHub

View File

@@ -1,5 +1,4 @@
private import cpp
private import semmle.code.cpp.dataflow.EscapesTree
predicate addressConstantExpression(Expr e) {
constantAddressPointer(e)
@@ -14,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()
}
/**