@@ -142,6 +142,9 @@ private class LogicalNotValueNumber extends ValueNumber {
142
142
/**
143
143
* A Boolean condition in the AST that guards one or more basic blocks. This includes
144
144
* 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.
145
148
*/
146
149
cached
147
150
class GuardCondition extends Expr {
@@ -451,6 +454,9 @@ private predicate nonExcludedIRAndBasicBlock(IRBlock irb, BasicBlock controlled)
451
454
*
452
455
* Note that `&&` and `||` don't have an explicit representation in the IR,
453
456
* 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.
454
460
*/
455
461
cached
456
462
class IRGuardCondition extends Instruction {
@@ -811,13 +817,20 @@ class IRGuardCondition extends Instruction {
811
817
}
812
818
813
819
private 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
+ )
815
830
or
816
831
exists ( LogicalNotInstruction cond |
817
832
result = getBranchForCondition ( cond ) and cond .getUnary ( ) = guard
818
833
)
819
- or
820
- result .( SwitchInstruction ) .getExpression ( ) = guard
821
834
}
822
835
823
836
/**
0 commit comments