@@ -49,6 +49,13 @@ private Element getRealParent(Expr expr) {
4949 )
5050}
5151
52+ /**
53+ * Holds if `expr` is a constant of a type that can be replaced directly with
54+ * its value in the IR. This does not include address constants as we have no
55+ * means to express those as QL values.
56+ */
57+ predicate isIRConstant ( Expr expr ) { exists ( expr .getValue ( ) ) }
58+
5259/**
5360 * Holds if `expr` and all of its descendants should be ignored for the purposes
5461 * of IR generation due to some property of `expr` itself. Unlike
@@ -63,7 +70,7 @@ private predicate ignoreExprAndDescendants(Expr expr) {
6370 getRealParent ( expr ) instanceof SwitchCase or
6471 // Ignore descendants of constant expressions, since we'll just substitute the
6572 // constant value.
66- getRealParent ( expr ) . ( Expr ) . isConstant ( ) or
73+ isIRConstant ( getRealParent ( expr ) ) or
6774 // The `DestructorCall` node for a `DestructorFieldDestruction` has a `FieldAccess`
6875 // node as its qualifier, but that `FieldAccess` does not have a child of its own.
6976 // We'll ignore that `FieldAccess`, and supply the receiver as part of the calling
@@ -146,7 +153,7 @@ private predicate translateStmt(Stmt stmt) {
146153 */
147154private predicate isNativeCondition ( Expr expr ) {
148155 expr instanceof BinaryLogicalOperation and
149- not expr . isConstant ( )
156+ not isIRConstant ( expr )
150157}
151158
152159/**
@@ -159,7 +166,7 @@ private predicate isFlexibleCondition(Expr expr) {
159166 expr instanceof NotExpr
160167 ) and
161168 usedAsCondition ( expr ) and
162- not expr . isConstant ( )
169+ not isIRConstant ( expr )
163170}
164171
165172/**
0 commit comments