Skip to content

Commit 316cb95

Browse files
committed
C++: respond to overflow PR comments
1 parent 18c3feb commit 316cb95

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/FloatDelta.qll

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module FloatDelta implements DeltaSig {
2121
}
2222

2323
module FloatOverflow implements OverflowSig<FloatDelta> {
24-
predicate semExprDoesntOverflow(boolean positively, SemExpr expr) {
24+
predicate semExprDoesNotOverflow(boolean positively, SemExpr expr) {
2525
exists(float lb, float ub, float delta |
2626
typeBounds(expr.getSemType(), lb, ub) and
2727
ConstantStage::initialBounded(expr, any(ConstantBounds::SemZeroBound b), delta, positively, _, _, _)
@@ -31,17 +31,8 @@ module FloatOverflow implements OverflowSig<FloatDelta> {
3131
positively = false and delta > lb
3232
)
3333
}
34-
/*
35-
predicate semExprOverflow(float delta, boolean upper, SemExpr expr) {
36-
exists(float lb, float ub | typeBounds(expr.getSemType(), lb, ub) |
37-
upper = false and delta < lb
38-
or
39-
upper = true and delta > ub
40-
)
41-
}
42-
*/
4334

44-
predicate typeBounds(SemType t, float lb, float ub) {
35+
additional predicate typeBounds(SemType t, float lb, float ub) {
4536
exists(SemIntegerType integralType, float limit |
4637
integralType = t and limit = 2.pow(8 * integralType.getByteSize())
4738
|

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisSpecific.qll renamed to cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisConstantSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.Semantic
66
private import RangeAnalysisStage
77
private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.FloatDelta
88

9-
module CppLangImpl implements LangSig<FloatDelta> {
9+
module CppLangImplConstant implements LangSig<FloatDelta> {
1010
/**
1111
* Holds if the specified expression should be excluded from the result of `ssaRead()`.
1212
*

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisImpl.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
private import RangeAnalysisStage
2-
private import RangeAnalysisSpecific
2+
private import RangeAnalysisConstantSpecific
3+
private import RangeAnalysisRelativeSpecific
34
private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.FloatDelta
45
private import RangeUtils
56
private import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticBound as SemanticBound
@@ -47,10 +48,10 @@ module RelativeBounds implements BoundSig<FloatDelta> {
4748
}
4849

4950
module ConstantStage =
50-
RangeStage<FloatDelta, ConstantBounds, FloatOverflow, CppLangImpl, RangeUtil<FloatDelta, CppLangImpl>>;
51+
RangeStage<FloatDelta, ConstantBounds, FloatOverflow, CppLangImplConstant, RangeUtil<FloatDelta, CppLangImplConstant>>;
5152

5253
module RelativeStage =
53-
RangeStage<FloatDelta, RelativeBounds, FloatOverflow, CppLangImpl, RangeUtil<FloatDelta, CppLangImpl>>;
54+
RangeStage<FloatDelta, RelativeBounds, FloatOverflow, CppLangImplRelative, RangeUtil<FloatDelta, CppLangImplRelative>>;
5455

5556
private newtype TSemReason =
5657
TSemNoReason() or

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisSpecific2.qll renamed to cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisRelativeSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.IntD
99
private import RangeAnalysisImpl
1010
private import semmle.code.cpp.rangeanalysis.RangeAnalysisUtils
1111

12-
module CppLangImpl2 implements LangSig<FloatDelta> {
12+
module CppLangImplRelative implements LangSig<FloatDelta> {
1313
/**
1414
* Holds if the specified expression should be excluded from the result of `ssaRead()`.
1515
*

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeAnalysisStage.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ signature module BoundSig<DeltaSig D> {
242242
}
243243

244244
signature module OverflowSig<DeltaSig D> {
245-
predicate semExprDoesntOverflow(boolean positively, SemExpr expr);
245+
predicate semExprDoesNotOverflow(boolean positively, SemExpr expr);
246246
}
247247

248248
module RangeStage<
@@ -935,12 +935,10 @@ module RangeStage<
935935
) {
936936
initialBounded(e, b, delta, upper, fromBackEdge, origdelta, reason) and
937937
(
938-
semExprDoesntOverflow(upper.booleanNot(), e)
938+
semExprDoesNotOverflow(upper.booleanNot(), e)
939939
or
940940
not potentiallyOverflowingExpr(upper.booleanNot(), e)
941941
or
942-
initialBounded(e, any(SemZeroBound z), _, upper.booleanNot(), _, _, _)
943-
or
944942
exists(D::Delta otherDelta |
945943
initialBounded(e, _, otherDelta, upper.booleanNot(), _, _, _) and
946944
(

cpp/ql/lib/semmle/code/cpp/rangeanalysis/new/internal/semantic/analysis/RangeUtils.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
private import semmle.code.cpp.rangeanalysis.new.internal.semantic.Semantic
6-
private import RangeAnalysisSpecific
6+
private import RangeAnalysisRelativeSpecific
77
private import RangeAnalysisStage as Range
88
private import ConstantAnalysis
99

0 commit comments

Comments
 (0)