11private import RangeAnalysisStage
2- private import RangeAnalysisSpecific
2+ private import RangeAnalysisConstantSpecific
3+ private import RangeAnalysisRelativeSpecific
34private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.FloatDelta
45private import RangeUtils
56private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticBound as SemanticBound
@@ -28,7 +29,7 @@ module ConstantBounds implements BoundSig<FloatDelta> {
2829 }
2930}
3031
31- private module RelativeBounds implements BoundSig< FloatDelta > {
32+ module RelativeBounds implements BoundSig< FloatDelta > {
3233 class SemBound instanceof SemanticBound:: SemBound {
3334 SemBound ( ) { not this instanceof SemanticBound:: SemZeroBound }
3435
@@ -46,11 +47,13 @@ private module RelativeBounds implements BoundSig<FloatDelta> {
4647 }
4748}
4849
49- private module ConstantStage =
50- RangeStage< FloatDelta , ConstantBounds , CppLangImpl , RangeUtil< FloatDelta , CppLangImpl > > ;
50+ module ConstantStage =
51+ RangeStage< FloatDelta , ConstantBounds , FloatOverflow , CppLangImplConstant ,
52+ RangeUtil< FloatDelta , CppLangImplConstant > > ;
5153
52- private module RelativeStage =
53- RangeStage< FloatDelta , RelativeBounds , CppLangImpl , RangeUtil< FloatDelta , CppLangImpl > > ;
54+ module RelativeStage =
55+ RangeStage< FloatDelta , RelativeBounds , FloatOverflow , CppLangImplRelative ,
56+ RangeUtil< FloatDelta , CppLangImplRelative > > ;
5457
5558private newtype TSemReason =
5659 TSemNoReason ( ) or
@@ -60,48 +63,52 @@ private newtype TSemReason =
6063 guard = any ( RelativeStage:: SemCondReason reason ) .getCond ( )
6164 }
6265
63- /**
64- * A reason for an inferred bound. This can either be `CondReason` if the bound
65- * is due to a specific condition, or `NoReason` if the bound is inferred
66- * without going through a bounding condition.
67- */
68- abstract class SemReason extends TSemReason {
69- /** Gets a textual representation of this reason. */
70- abstract string toString ( ) ;
71- }
72-
73- /**
74- * A reason for an inferred bound that indicates that the bound is inferred
75- * without going through a bounding condition.
76- */
77- class SemNoReason extends SemReason , TSemNoReason {
78- override string toString ( ) { result = "NoReason" }
79- }
80-
81- /** A reason for an inferred bound pointing to a condition. */
82- class SemCondReason extends SemReason , TSemCondReason {
83- /** Gets the condition that is the reason for the bound. */
84- SemGuard getCond ( ) { this = TSemCondReason ( result ) }
85-
86- override string toString ( ) { result = getCond ( ) .toString ( ) }
87- }
88-
89- private ConstantStage:: SemReason constantReason ( SemReason reason ) {
66+ ConstantStage:: SemReason constantReason ( SemReason reason ) {
9067 result instanceof ConstantStage:: SemNoReason and reason instanceof SemNoReason
9168 or
9269 result .( ConstantStage:: SemCondReason ) .getCond ( ) = reason .( SemCondReason ) .getCond ( )
9370}
9471
95- private RelativeStage:: SemReason relativeReason ( SemReason reason ) {
72+ RelativeStage:: SemReason relativeReason ( SemReason reason ) {
9673 result instanceof RelativeStage:: SemNoReason and reason instanceof SemNoReason
9774 or
9875 result .( RelativeStage:: SemCondReason ) .getCond ( ) = reason .( SemCondReason ) .getCond ( )
9976}
10077
101- predicate semBounded (
102- SemExpr e , SemanticBound:: SemBound b , float delta , boolean upper , SemReason reason
103- ) {
104- ConstantStage:: semBounded ( e , b , delta , upper , constantReason ( reason ) )
105- or
106- RelativeStage:: semBounded ( e , b , delta , upper , relativeReason ( reason ) )
78+ import Public
79+
80+ module Public {
81+ predicate semBounded (
82+ SemExpr e , SemanticBound:: SemBound b , float delta , boolean upper , SemReason reason
83+ ) {
84+ ConstantStage:: semBounded ( e , b , delta , upper , constantReason ( reason ) )
85+ or
86+ RelativeStage:: semBounded ( e , b , delta , upper , relativeReason ( reason ) )
87+ }
88+
89+ /**
90+ * A reason for an inferred bound. This can either be `CondReason` if the bound
91+ * is due to a specific condition, or `NoReason` if the bound is inferred
92+ * without going through a bounding condition.
93+ */
94+ abstract class SemReason extends TSemReason {
95+ /** Gets a textual representation of this reason. */
96+ abstract string toString ( ) ;
97+ }
98+
99+ /**
100+ * A reason for an inferred bound that indicates that the bound is inferred
101+ * without going through a bounding condition.
102+ */
103+ class SemNoReason extends SemReason , TSemNoReason {
104+ override string toString ( ) { result = "NoReason" }
105+ }
106+
107+ /** A reason for an inferred bound pointing to a condition. */
108+ class SemCondReason extends SemReason , TSemCondReason {
109+ /** Gets the condition that is the reason for the bound. */
110+ SemGuard getCond ( ) { this = TSemCondReason ( result ) }
111+
112+ override string toString ( ) { result = getCond ( ) .toString ( ) }
113+ }
107114}
0 commit comments