@@ -142,6 +142,9 @@ private class LogicalNotValueNumber extends ValueNumber {
142142/**
143143 * A Boolean condition in the AST that guards one or more basic blocks. This includes
144144 * operands of logical operators but not switch statements.
145+ *
146+ * For performance reasons conditions inside static local initializers or
147+ * global initializers are not considered `GuardCondition`s.
145148 */
146149cached
147150class GuardCondition extends Expr {
@@ -451,6 +454,9 @@ private predicate nonExcludedIRAndBasicBlock(IRBlock irb, BasicBlock controlled)
451454 *
452455 * Note that `&&` and `||` don't have an explicit representation in the IR,
453456 * and therefore will not appear as IRGuardConditions.
457+ *
458+ * For performance reasons conditions inside static local initializers or
459+ * global initializers are not considered `IRGuardCondition`s.
454460 */
455461cached
456462class IRGuardCondition extends Instruction {
@@ -811,13 +817,20 @@ class IRGuardCondition extends Instruction {
811817}
812818
813819private Instruction getBranchForCondition ( Instruction guard ) {
814- result .( ConditionalBranchInstruction ) .getCondition ( ) = guard
820+ // There are a lot of guards inside global or static local initializers,
821+ // and on certain databases this can make the `ensures*` predicates
822+ // blow up.
823+ // These guards are likely not super important anyway.
824+ guard .getEnclosingFunction ( ) instanceof Function and
825+ (
826+ result .( ConditionalBranchInstruction ) .getCondition ( ) = guard
827+ or
828+ result .( SwitchInstruction ) .getExpression ( ) = guard
829+ )
815830 or
816831 exists ( LogicalNotInstruction cond |
817832 result = getBranchForCondition ( cond ) and cond .getUnary ( ) = guard
818833 )
819- or
820- result .( SwitchInstruction ) .getExpression ( ) = guard
821834}
822835
823836/**
0 commit comments