@@ -187,8 +187,9 @@ private class MaxValueState extends TMaxValueState {
187
187
* If the architecture bit size is known, then we should use that. Otherwise,
188
188
* we should use 32 bits, because that will lead to more results.
189
189
*/
190
- int getSinkBitSize ( ) {
191
- if this = TMkMaxValueState ( _, TMk64Bit ( ) ) then result = 64 else result = 32
190
+ bindingset [ default]
191
+ int getSinkBitSize ( int default ) {
192
+ if this = TMkMaxValueState ( _, TMk64Bit ( ) ) then result = 64 else result = default
192
193
}
193
194
194
195
/** Gets a textual representation of this element. */
@@ -242,7 +243,7 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
242
243
}
243
244
244
245
override predicate barrierFor ( MaxValueState flowstate ) {
245
- g .isBoundFor2 ( flowstate .getBitSize ( ) , flowstate .getSinkBitSize ( ) )
246
+ g .isBoundFor2 ( flowstate .getBitSize ( ) , flowstate .getSinkBitSize ( 32 ) )
246
247
}
247
248
248
249
override MaxValueState transform ( MaxValueState state ) {
@@ -251,7 +252,7 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
251
252
max ( int bitsize |
252
253
bitsize = validBitSize ( ) and
253
254
bitsize < state .getBitSize ( ) and
254
- not g .isBoundFor2 ( bitsize , state .getSinkBitSize ( ) )
255
+ not g .isBoundFor2 ( bitsize , state .getSinkBitSize ( 32 ) )
255
256
|
256
257
bitsize
257
258
) and
@@ -325,20 +326,22 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
325
326
*/
326
327
additional predicate isSink2 ( DataFlow:: TypeCastNode sink , FlowState state ) {
327
328
sink .asExpr ( ) instanceof ConversionExpr and
328
- exists ( IntegerType integerType , int sinkBitsize , boolean sinkIsSigned |
329
+ exists ( int architectureBitSize , IntegerType integerType , int sinkBitsize , boolean sinkIsSigned |
330
+ architectureBitSize = getIntTypeBitSize ( sink .getFile ( ) , state .getSinkBitSize ( 32 ) ) and
331
+ not ( state .getArchitectureBitSize ( ) = 32 and architectureBitSize = 64 ) and
329
332
sink .getResultType ( ) .getUnderlyingType ( ) = integerType and
330
333
(
331
334
sinkBitsize = integerType .getSize ( )
332
335
or
333
336
not exists ( integerType .getSize ( ) ) and
334
- sinkBitsize = getIntTypeBitSize ( sink . getFile ( ) , 0 )
337
+ sinkBitsize = 0
335
338
) and
336
339
(
337
340
if integerType instanceof SignedIntegerType
338
341
then sinkIsSigned = true
339
342
else sinkIsSigned = false
340
343
) and
341
- adjustBitSize ( sinkBitsize , sinkIsSigned , state . getSinkBitSize ( ) ) < state .getBitSize ( )
344
+ adjustBitSize ( sinkBitsize , sinkIsSigned , architectureBitSize ) < state .getBitSize ( )
342
345
) and
343
346
not exists ( ShrExpr shrExpr |
344
347
shrExpr .getLeftOperand ( ) .getGlobalValueNumber ( ) =
0 commit comments