@@ -195,8 +195,13 @@ private class MaxValueState extends TMaxValueState {
195
195
*/
196
196
int getBitSize ( ) { this = TMkMaxValueState ( result , _) }
197
197
198
- /** Gets whether the architecture is 32 bit or 64 bit, or if it is unknown. */
199
- ArchitectureBitSize getArchitectureBitSize ( ) { this = TMkMaxValueState ( _, result ) }
198
+ private ArchitectureBitSize architectureBitSize ( ) { this = TMkMaxValueState ( _, result ) }
199
+
200
+ /** Gets whether the architecture is 32 bit or 64 bit, if it is known. */
201
+ int getArchitectureBitSize ( ) { result = this .architectureBitSize ( ) .toInt ( ) }
202
+
203
+ /** Holds if the architecture is not known. */
204
+ predicate architectureBitSizeUnknown ( ) { this .architectureBitSize ( ) .isUnknown ( ) }
200
205
201
206
/**
202
207
* Gets the bitsize we should use for a sink.
@@ -213,9 +218,9 @@ private class MaxValueState extends TMaxValueState {
213
218
/** Gets a textual representation of this element. */
214
219
string toString ( ) {
215
220
exists ( string suffix |
216
- suffix = " (on " + this .getArchitectureBitSize ( ) . toInt ( ) + "-bit architecture)"
221
+ suffix = " (on " + this .getArchitectureBitSize ( ) + "-bit architecture)"
217
222
or
218
- this .getArchitectureBitSize ( ) . isUnknown ( ) and suffix = ""
223
+ this .architectureBitSizeUnknown ( ) and suffix = ""
219
224
|
220
225
result = "MaxValueState(max value <= 2^(" + this .getBitSize ( ) + ")-1" + suffix
221
226
)
@@ -351,7 +356,11 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
351
356
// this will find results that only exist on 32-bit architectures.
352
357
not g .isBoundFor ( bitsize , state .getSinkBitSize ( 32 ) )
353
358
) and
354
- result .getArchitectureBitSize ( ) = state .getArchitectureBitSize ( )
359
+ (
360
+ result .getArchitectureBitSize ( ) = state .getArchitectureBitSize ( )
361
+ or
362
+ state .architectureBitSizeUnknown ( ) and result .architectureBitSizeUnknown ( )
363
+ )
355
364
}
356
365
}
357
366
@@ -395,10 +404,10 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
395
404
then
396
405
exists ( int b | b = [ 32 , 64 ] |
397
406
state .getBitSize ( ) = adjustBitSize ( 0 , sourceIsSigned , b ) and
398
- state .getArchitectureBitSize ( ) . toInt ( ) = b
407
+ state .getArchitectureBitSize ( ) = b
399
408
)
400
409
else (
401
- state .getArchitectureBitSize ( ) . isUnknown ( ) and
410
+ state .architectureBitSizeUnknown ( ) and
402
411
state .getBitSize ( ) =
403
412
min ( int bitsize |
404
413
bitsize = validBitSize ( ) and
@@ -422,7 +431,7 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
422
431
// Use a default value of 32 for `MaxValueState.getSinkBitSize` because
423
432
// this will find results that only exist on 32-bit architectures.
424
433
architectureBitSize = getIntTypeBitSize ( sink .getFile ( ) , state .getSinkBitSize ( 32 ) ) and
425
- not ( state .getArchitectureBitSize ( ) . toInt ( ) = 32 and architectureBitSize = 64 ) and
434
+ not ( state .getArchitectureBitSize ( ) = 32 and architectureBitSize = 64 ) and
426
435
sink .getResultType ( ) .getUnderlyingType ( ) = integerType and
427
436
(
428
437
sinkBitsize = integerType .getSize ( )
0 commit comments