mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Merge pull request #1326 from jbj/addressConstantVariable-isConstexpr
C++: Use isConstexpr instead of workaround in AddressConstantExpr
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user