Skip to content

Commit b169ccf

Browse files
committed
C++: Fully delete TRange.
1 parent a07d03f commit b169ccf

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,10 @@ module GuardsInput implements SharedGuards::InputSig<Cpp::Location, Instruction,
3030
IRCfg::BasicBlock getBasicBlock() { result = this.getBlock() }
3131
}
3232

33-
private newtype TConstantValue =
34-
// This is slightly abusing the shared guards library. Using
35-
// `TRange(40, 50)` to model a constant expression in the program such as
36-
// the literal "42" causes the shared guards library to make incorrect
37-
// inferences.
38-
// However, since we only use them to model `CaseConstant::asConstantValue`
39-
// this does not cause any wrong inferences (at least for now).
40-
TRange(string minValue, string maxValue) {
41-
minValue != maxValue and
42-
exists(EdgeKind::caseEdge(minValue, maxValue))
43-
}
44-
4533
/**
46-
* The constant values that can be inferred. The only additional constant
47-
* value required is the GCC extension for case ranges.
34+
* The constant values that can be inferred.
4835
*/
49-
class ConstantValue extends TConstantValue {
50-
/**
51-
* Holds if this constant value is the case range `minValue..maxValue`.
52-
*/
53-
predicate isRange(string minValue, string maxValue) { this = TRange(minValue, maxValue) }
54-
55-
string toString() {
56-
exists(string minValue, string maxValue |
57-
this.isRange(minValue, maxValue) and
58-
result = minValue + ".." + maxValue
59-
)
60-
}
61-
}
36+
class ConstantValue = Void;
6237

6338
private class EqualityExpr extends CompareInstruction {
6439
EqualityExpr() {
@@ -508,22 +483,10 @@ deprecated class BooleanValue extends AbstractValue {
508483
* A value that represents a match against a specific `switch` case.
509484
*/
510485
deprecated class MatchValue extends AbstractValue {
511-
MatchValue() {
512-
exists(this.asIntValue())
513-
or
514-
this.asConstantValue().isRange(_, _)
515-
}
486+
MatchValue() { exists(this.asIntValue()) }
516487

517488
/** Gets the case. */
518-
CaseEdge getCase() {
519-
result.getValue().toInt() = this.asIntValue()
520-
or
521-
exists(string minValue, string maxValue |
522-
result.getMinValue() = minValue and
523-
result.getMaxValue() = maxValue and
524-
this.asConstantValue().isRange(minValue, maxValue)
525-
)
526-
}
489+
CaseEdge getCase() { result.getValue().toInt() = this.asIntValue() }
527490
}
528491

529492
/**

0 commit comments

Comments
 (0)