@@ -17,9 +17,12 @@ private newtype TBufferWriteEstimationReason =
17
17
18
18
private predicate gradeToReason ( int grade , TBufferWriteEstimationReason reason ) {
19
19
// when combining reasons, lower grade takes precedence
20
- grade = 0 and reason = TUnspecifiedEstimateReason ( ) or
21
- grade = 1 and reason = TTypeBoundsAnalysis ( ) or
22
- grade = 2 and reason = TWidenedValueFlowAnalysis ( ) or
20
+ grade = 0 and reason = TUnspecifiedEstimateReason ( )
21
+ or
22
+ grade = 1 and reason = TTypeBoundsAnalysis ( )
23
+ or
24
+ grade = 2 and reason = TWidenedValueFlowAnalysis ( )
25
+ or
23
26
grade = 3 and reason = TValueFlowAnalysis ( )
24
27
}
25
28
@@ -42,8 +45,10 @@ abstract class BufferWriteEstimationReason extends TBufferWriteEstimationReason
42
45
* conversion given reasons coming from its individual specifiers.
43
46
*/
44
47
BufferWriteEstimationReason combineWith ( BufferWriteEstimationReason other ) {
45
- exists ( int grade , int otherGrade | gradeToReason ( grade , this ) and gradeToReason ( otherGrade , other ) |
46
- if otherGrade < grade then result = other else result = this
48
+ exists ( int grade , int otherGrade |
49
+ gradeToReason ( grade , this ) and gradeToReason ( otherGrade , other )
50
+ |
51
+ if otherGrade < grade then result = other else result = this
47
52
)
48
53
}
49
54
}
@@ -83,10 +88,11 @@ class TypeBoundsAnalysis extends BufferWriteEstimationReason, TTypeBoundsAnalysi
83
88
class WidenedValueFlowAnalysis extends BufferWriteEstimationReason , TWidenedValueFlowAnalysis {
84
89
override string toString ( ) { result = "WidenedValueFlowAnalysis" }
85
90
86
- override string getDescription ( ) { result = "based on flow analysis of value bounds with a widening approximation" }
91
+ override string getDescription ( ) {
92
+ result = "based on flow analysis of value bounds with a widening approximation"
93
+ }
87
94
}
88
95
89
-
90
96
/**
91
97
* The estimation comes from non trivial bounds found via actual flow analysis.
92
98
* For example
@@ -381,12 +387,17 @@ private BufferWriteEstimationReason getEstimationReasonForIntegralExpression(Exp
381
387
// * constrained non-trivially both sides of a signed value, or
382
388
// * constrained non-trivially the positive side of an unsigned value
383
389
// expr should already be given as getFullyConverted
384
- if upperBound ( expr ) < exprMaxVal ( expr ) and ( exprMinVal ( expr ) >= 0 or lowerBound ( expr ) > exprMinVal ( expr ) )
385
- // next we check whether the estimate may have been widened
386
- then if upperBoundMayBeWidened ( expr ) then result = TWidenedValueFlowAnalysis ( )
387
- else result = TValueFlowAnalysis ( )
390
+ if
391
+ upperBound ( expr ) < exprMaxVal ( expr ) and
392
+ ( exprMinVal ( expr ) >= 0 or lowerBound ( expr ) > exprMinVal ( expr ) )
393
+ then
394
+ // next we check whether the estimate may have been widened
395
+ if upperBoundMayBeWidened ( expr )
396
+ then result = TWidenedValueFlowAnalysis ( )
397
+ else result = TValueFlowAnalysis ( )
388
398
else result = TTypeBoundsAnalysis ( )
389
399
}
400
+
390
401
/**
391
402
* A class to represent format strings that occur as arguments to invocations of formatting functions.
392
403
*/
0 commit comments