44overlay [ local?]
55module ;
66
7+ private import csharp as CS
78private import internal.rangeanalysis.BoundSpecific
9+ private import internal.rangeanalysis.BoundSpecific as BoundSpecific
10+ private import codeql.rangeanalysis.Bound as SharedBound
811
9- private newtype TBound =
10- TBoundZero( ) or
11- TBoundSsa( SsaVariable v) { v.getSourceVariable( ) .getType( ) instanceof IntegralType } or
12- TBoundExpr( Expr e) {
13- interestingExprBound( e) and
14- not exists ( SsaVariable v | e = v.getAUse( ) )
15- }
12+ private module BoundImpl = SharedBound:: Bound< CS:: Location , BoundSpecific:: BoundDefs > ;
1613
1714/**
1815 * A bound that may be inferred for an expression plus/minus an integer delta.
1916 */
20- abstract class Bound extends TBound {
21- /** Gets a textual representation of this bound. */
22- abstract string toString ( ) ;
23-
24- /** Gets an expression that equals this bound plus `delta`. */
25- abstract Expr getExpr ( int delta ) ;
26-
27- /** Gets an expression that equals this bound. */
28- Expr getExpr ( ) { result = this .getExpr ( 0 ) }
29-
30- /** Gets the location of this bound. */
31- abstract Location getLocation ( ) ;
32- }
17+ class Bound = BoundImpl:: Bound ;
3318
3419/**
3520 * The bound that corresponds to the integer 0. This is used to represent all
3621 * integer bounds as bounds are always accompanied by an added integer delta.
3722 */
38- class ZeroBound extends Bound , TBoundZero {
39- override string toString ( ) { result = "0" }
40-
41- override Expr getExpr ( int delta ) { result .( ConstantIntegerExpr ) .getIntValue ( ) = delta }
42-
43- override Location getLocation ( ) { result .hasLocationInfo ( "" , 0 , 0 , 0 , 0 ) }
44- }
23+ class ZeroBound = BoundImpl:: ZeroBound ;
4524
4625/**
4726 * A bound corresponding to the value of an SSA variable.
4827 */
49- class SsaBound extends Bound , TBoundSsa {
50- /** Gets the SSA variable that equals this bound. */
51- SsaVariable getSsa ( ) { this = TBoundSsa ( result ) }
52-
53- override string toString ( ) { result = this .getSsa ( ) .toString ( ) }
54-
55- override Expr getExpr ( int delta ) { result = this .getSsa ( ) .getAUse ( ) and delta = 0 }
56-
57- override Location getLocation ( ) { result = this .getSsa ( ) .getLocation ( ) }
58- }
28+ class SsaBound = BoundImpl:: SsaBound ;
5929
6030/**
6131 * A bound that corresponds to the value of a specific expression that might be
6232 * interesting, but isn't otherwise represented by the value of an SSA variable.
6333 */
64- class ExprBound extends Bound , TBoundExpr {
65- override string toString ( ) { result = this .getExpr ( ) .toString ( ) }
66-
67- override Expr getExpr ( int delta ) { this = TBoundExpr ( result ) and delta = 0 }
68-
69- override Location getLocation ( ) { result = this .getExpr ( ) .getLocation ( ) }
70- }
34+ class ExprBound = BoundImpl:: ExprBound ;
0 commit comments