Skip to content

Commit c70e13b

Browse files
committed
C++: Add toString for RelationStrictness
1 parent a72589d commit c70e13b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeAnalysisUtils.qll

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cpp
44
* Describes whether a relation is 'strict' (that is, a `<` or `>`
55
* relation) or 'non-strict' (a `<=` or `>=` relation).
66
*/
7-
newtype RelationStrictness =
7+
newtype TRelationStrictness =
88
/**
99
* Represents that a relation is 'strict' (that is, a `<` or `>` relation).
1010
*/
@@ -14,6 +14,14 @@ newtype RelationStrictness =
1414
*/
1515
Nonstrict()
1616

17+
class RelationStrictness extends TRelationStrictness {
18+
string toString() {
19+
this = Strict() and result = "strict"
20+
or
21+
this = Nonstrict() and result = "non-strict"
22+
}
23+
}
24+
1725
/**
1826
* Describes whether a relation is 'greater' (that is, a `>` or `>=`
1927
* relation) or 'lesser' (a `<` or `<=` relation).
@@ -105,10 +113,10 @@ predicate relOpWithSwap(
105113
*
106114
* This allows for the relation to be either as written, or with its
107115
* arguments reversed; for example, if `rel` is `x < 5` then
108-
* `relOpWithSwapAndNegate(rel, x, 5, Lesser(), Strict(), true)`,
109-
* `relOpWithSwapAndNegate(rel, 5, x, Greater(), Strict(), true)`,
110-
* `relOpWithSwapAndNegate(rel, x, 5, Greater(), Nonstrict(), false)` and
111-
* `relOpWithSwapAndNegate(rel, 5, x, Lesser(), Nonstrict(), false)` hold.
116+
* - `relOpWithSwapAndNegate(rel, x, 5, Lesser(), Strict(), true)`,
117+
* - `relOpWithSwapAndNegate(rel, 5, x, Greater(), Strict(), true)`,
118+
* - `relOpWithSwapAndNegate(rel, x, 5, Greater(), Nonstrict(), false)` and
119+
* - `relOpWithSwapAndNegate(rel, 5, x, Lesser(), Nonstrict(), false)` hold.
112120
*/
113121
predicate relOpWithSwapAndNegate(
114122
RelationalOperation rel, Expr a, Expr b, RelationDirection dir, RelationStrictness strict,

0 commit comments

Comments
 (0)