Skip to content

Commit bf7732e

Browse files
committed
C++: Silence QL compiler errors
1 parent 1deb1e6 commit bf7732e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cpp/ql/src/experimental/semmle/code/cpp/models/interfaces/SimpleRangeAnalysisExpr.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,23 @@ abstract class SimpleRangeAnalysisExpr extends Expr {
5656
}
5757

5858
import SimpleRangeAnalysisInternal
59+
60+
/**
61+
* This class exists to prevent the QL front end from emitting compile errors
62+
* inside `SimpleRangeAnalysis.qll` about certain conjuncts being empty
63+
* because the overrides of `SimpleRangeAnalysisExpr` that happen to be in
64+
* scope do not make use of every feature it offers.
65+
*/
66+
private class Empty extends SimpleRangeAnalysisExpr {
67+
Empty() {
68+
// This predicate is complicated enough that the QL type checker doesn't
69+
// see it as empty but simple enough that the optimizer should.
70+
this = this and none()
71+
}
72+
73+
override float getLowerBounds() { none() }
74+
75+
override float getUpperBounds() { none() }
76+
77+
override predicate dependsOnChild(Expr child) { none() }
78+
}

0 commit comments

Comments
 (0)