@@ -10,25 +10,54 @@ import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
1010/**
1111 * EXPERIMENTAL: The API of this class may change without notice.
1212 *
13- * An SSA definition for which a range can be deduced. Extend this class to add
14- * functionality to the range analysis library.
13+ * An SSA definition for which a range can be deduced. As with
14+ * `RangeSsaDefinition` and `SsaDefinition`, instances of this class
15+ * correspond to points in the program where one or more variables are defined
16+ * or have their value constrained in some way.
17+ *
18+ * Extend this class to add functionality to the range analysis library.
1519 */
1620abstract class SimpleRangeAnalysisDefinition extends RangeSsaDefinition {
17- /**
18- * Gets the lower bound of the defomotopn.
21+ /**
22+ * Holds if this `SimpleRangeAnalysisDefinition` adds range information for
23+ * `v`. Because a `SimpleRangeAnalysisDefinition` is just a point in the
24+ * program, it's possible that more than one variable might be defined at
25+ * this point. This predicate clarifies which variable(s) should get range
26+ * information from `this`.
27+ *
28+ * This predicate **must be overridden** to hold for any `v` that can show
29+ * up in the other members of `SimpleRangeAnalysisDefinition`. Conversely,
30+ * the other members **must be accurate** for any `v` in this predicate.
31+ */
32+ abstract predicate hasRangeInformationFor ( StackVariable v ) ;
33+
34+ /**
35+ * Holds if `(this, v)` depends on the range of the unconverted expression
36+ * `e`. This information is used to inform the range analysis about cyclic
37+ * dependencies. Without this information, range analysis might work for
38+ * simple cases but will go into infinite loops on complex code.
39+ *
40+ * For example, when modelling the definition by reference in a call to an
41+ * overloaded `operator=`, written as `v = e`, the definition of `(this, v)`
42+ * depends on `e`.
43+ */
44+ abstract predicate dependsOnExpr ( StackVariable v , Expr e ) ;
45+
46+ /**
47+ * Gets the lower bound of the variable `v` defined by this definition.
1948 *
2049 * Implementations of this predicate should use
2150 * `getFullyConvertedLowerBounds` and `getFullyConvertedUpperBounds` for
22- * recursive calls to get the bounds of their children .
51+ * recursive calls to get the bounds of their dependencies .
2352 */
24- abstract float getLowerBounds ( ) ;
53+ abstract float getLowerBounds ( StackVariable v ) ;
2554
2655 /**
27- * Gets the upper bound of the definition.
56+ * Gets the upper bound of the variable `v` defined by this definition.
2857 *
2958 * Implementations of this predicate should use
3059 * `getFullyConvertedLowerBounds` and `getFullyConvertedUpperBounds` for
31- * recursive calls to get the bounds of their children .
60+ * recursive calls to get the bounds of their dependencies .
3261 */
33- abstract float getUpperBounds ( ) ;
34- }
62+ abstract float getUpperBounds ( StackVariable v ) ;
63+ }
0 commit comments