@@ -195,8 +195,13 @@ private class MaxValueState extends TMaxValueState {
195195 */
196196 int getBitSize ( ) { this = TMkMaxValueState ( result , _) }
197197
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 ( ) }
200205
201206 /**
202207 * Gets the bitsize we should use for a sink.
@@ -213,9 +218,9 @@ private class MaxValueState extends TMaxValueState {
213218 /** Gets a textual representation of this element. */
214219 string toString ( ) {
215220 exists ( string suffix |
216- suffix = " (on " + this .getArchitectureBitSize ( ) . toInt ( ) + "-bit architecture)"
221+ suffix = " (on " + this .getArchitectureBitSize ( ) + "-bit architecture)"
217222 or
218- this .getArchitectureBitSize ( ) . isUnknown ( ) and suffix = ""
223+ this .architectureBitSizeUnknown ( ) and suffix = ""
219224 |
220225 result = "MaxValueState(max value <= 2^(" + this .getBitSize ( ) + ")-1" + suffix
221226 )
@@ -351,7 +356,11 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
351356 // this will find results that only exist on 32-bit architectures.
352357 not g .isBoundFor ( bitsize , state .getSinkBitSize ( 32 ) )
353358 ) and
354- result .getArchitectureBitSize ( ) = state .getArchitectureBitSize ( )
359+ (
360+ result .getArchitectureBitSize ( ) = state .getArchitectureBitSize ( )
361+ or
362+ state .architectureBitSizeUnknown ( ) and result .architectureBitSizeUnknown ( )
363+ )
355364 }
356365}
357366
@@ -395,10 +404,10 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
395404 then
396405 exists ( int b | b = [ 32 , 64 ] |
397406 state .getBitSize ( ) = adjustBitSize ( 0 , sourceIsSigned , b ) and
398- state .getArchitectureBitSize ( ) . toInt ( ) = b
407+ state .getArchitectureBitSize ( ) = b
399408 )
400409 else (
401- state .getArchitectureBitSize ( ) . isUnknown ( ) and
410+ state .architectureBitSizeUnknown ( ) and
402411 state .getBitSize ( ) =
403412 min ( int bitsize |
404413 bitsize = validBitSize ( ) and
@@ -422,7 +431,7 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
422431 // Use a default value of 32 for `MaxValueState.getSinkBitSize` because
423432 // this will find results that only exist on 32-bit architectures.
424433 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
426435 sink .getResultType ( ) .getUnderlyingType ( ) = integerType and
427436 (
428437 sinkBitsize = integerType .getSize ( )
0 commit comments