@@ -873,77 +873,85 @@ module Make<LocationSig Location, InputSig<Location> Input> {
873
873
874
874
private signature predicate baseGuardValueSig ( Guard guard , GuardValue v ) ;
875
875
876
- /**
877
- * Calculates the transitive closure of all the guard implication steps
878
- * starting from a given set of base cases.
879
- */
880
876
cached
881
- private module ImpliesTC < baseGuardValueSig / 2 baseGuardValue > {
877
+ private module Cached {
882
878
/**
883
- * Holds if `tgtGuard` evaluating to `tgtVal` implies that ` guard`
884
- * evaluates to `v` .
879
+ * Calculates the transitive closure of all the guard implication steps
880
+ * starting from a given set of base cases .
885
881
*/
886
- pragma [ nomagic]
887
882
cached
888
- predicate guardControls ( Guard guard , GuardValue v , Guard tgtGuard , GuardValue tgtVal ) {
889
- baseGuardValue ( tgtGuard , tgtVal ) and
890
- guard = tgtGuard and
891
- v = tgtVal
892
- or
893
- exists ( Guard g0 , GuardValue v0 |
894
- guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
895
- impliesStep2 ( g0 , v0 , guard , v )
896
- )
897
- or
898
- exists ( Guard g0 , GuardValue v0 |
899
- guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
900
- unboundImpliesStep ( g0 , v0 , guard , v )
901
- )
902
- or
903
- exists ( SsaDefinition def0 , GuardValue v0 |
904
- ssaControls ( def0 , v0 , tgtGuard , tgtVal ) and
905
- impliesStepSsaGuard ( def0 , v0 , guard , v )
906
- )
907
- or
908
- exists ( Guard g0 , GuardValue v0 |
909
- guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
910
- WrapperGuard:: wrapperImpliesStep ( g0 , v0 , guard , v )
911
- )
912
- or
913
- exists ( Guard g0 , GuardValue v0 |
914
- guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
915
- additionalImpliesStep ( g0 , v0 , guard , v )
916
- )
883
+ module ImpliesTC< baseGuardValueSig / 2 baseGuardValue> {
884
+ /**
885
+ * Holds if `tgtGuard` evaluating to `tgtVal` implies that `guard`
886
+ * evaluates to `v`.
887
+ */
888
+ pragma [ nomagic]
889
+ cached
890
+ predicate guardControls ( Guard guard , GuardValue v , Guard tgtGuard , GuardValue tgtVal ) {
891
+ baseGuardValue ( tgtGuard , tgtVal ) and
892
+ guard = tgtGuard and
893
+ v = tgtVal
894
+ or
895
+ exists ( Guard g0 , GuardValue v0 |
896
+ guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
897
+ impliesStep2 ( g0 , v0 , guard , v )
898
+ )
899
+ or
900
+ exists ( Guard g0 , GuardValue v0 |
901
+ guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
902
+ unboundImpliesStep ( g0 , v0 , guard , v )
903
+ )
904
+ or
905
+ exists ( SsaDefinition def0 , GuardValue v0 |
906
+ ssaControls ( def0 , v0 , tgtGuard , tgtVal ) and
907
+ impliesStepSsaGuard ( def0 , v0 , guard , v )
908
+ )
909
+ or
910
+ exists ( Guard g0 , GuardValue v0 |
911
+ guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
912
+ WrapperGuard:: wrapperImpliesStep ( g0 , v0 , guard , v )
913
+ )
914
+ or
915
+ exists ( Guard g0 , GuardValue v0 |
916
+ guardControls ( g0 , v0 , tgtGuard , tgtVal ) and
917
+ additionalImpliesStep ( g0 , v0 , guard , v )
918
+ )
919
+ }
920
+
921
+ /**
922
+ * Holds if `tgtGuard` evaluating to `tgtVal` implies that `def`
923
+ * evaluates to `v`.
924
+ */
925
+ pragma [ nomagic]
926
+ cached
927
+ predicate ssaControls ( SsaDefinition def , GuardValue v , Guard tgtGuard , GuardValue tgtVal ) {
928
+ exists ( Guard g0 |
929
+ guardControls ( g0 , v , tgtGuard , tgtVal ) and
930
+ guardReadsSsaVar ( g0 , def )
931
+ )
932
+ or
933
+ exists ( SsaDefinition def0 |
934
+ ssaControls ( def0 , v , tgtGuard , tgtVal ) and
935
+ impliesStepSsa ( def0 , v , def )
936
+ )
937
+ }
917
938
}
918
939
919
940
/**
920
- * Holds if `tgtGuard ` evaluating to `tgtVal ` implies that `def`
921
- * evaluates to `v` .
941
+ * Holds if `guard ` evaluating to `v ` implies that `e` is guaranteed to be
942
+ * null if `isNull` is true, and non-null if `isNull` is false .
922
943
*/
923
- pragma [ nomagic]
924
944
cached
925
- predicate ssaControls ( SsaDefinition def , GuardValue v , Guard tgtGuard , GuardValue tgtVal ) {
926
- exists ( Guard g0 |
927
- guardControls ( g0 , v , tgtGuard , tgtVal ) and
928
- guardReadsSsaVar ( g0 , def )
929
- )
930
- or
931
- exists ( SsaDefinition def0 |
932
- ssaControls ( def0 , v , tgtGuard , tgtVal ) and
933
- impliesStepSsa ( def0 , v , def )
934
- )
945
+ predicate nullGuard ( Guard guard , GuardValue v , Expr e , boolean isNull ) {
946
+ impliesStep2 ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) ) or
947
+ WrapperGuard:: wrapperImpliesStep ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) ) or
948
+ additionalImpliesStep ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) )
935
949
}
936
950
}
937
951
938
- /**
939
- * Holds if `guard` evaluating to `v` implies that `e` is guaranteed to be
940
- * null if `isNull` is true, and non-null if `isNull` is false.
941
- */
942
- predicate nullGuard ( Guard guard , GuardValue v , Expr e , boolean isNull ) {
943
- impliesStep2 ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) ) or
944
- WrapperGuard:: wrapperImpliesStep ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) ) or
945
- additionalImpliesStep ( guard , v , e , any ( GuardValue gv | gv .isNullness ( isNull ) ) )
946
- }
952
+ private import Cached
953
+
954
+ predicate nullGuard = Cached:: nullGuard / 4 ;
947
955
948
956
private predicate hasAValueBranchEdge ( Guard guard , GuardValue v ) {
949
957
guard .hasValueBranchEdge ( _, _, v )
0 commit comments