@@ -75,18 +75,18 @@ where
75
75
withinIntegralRange ( underlyingTypeAfter , [ upperBound ( c .getExpr ( ) ) , lowerBound ( c .getExpr ( ) ) ] )
76
76
or
77
77
// Heuristic - is there are guard the abs value of the float can fit in the precision of an int?
78
- exists ( GuardCondition gc , FunctionCall log2f , FunctionCall fabsf , Expr precision |
78
+ exists ( GuardCondition gc , FunctionCall log2 , FunctionCall fabs , Expr precision |
79
79
// gc.controls(c, false) and
80
- log2f .getTarget ( ) .hasGlobalOrStdName ( "log2f" ) and
81
- fabsf .getTarget ( ) .hasGlobalOrStdName ( "fabsf" ) and
82
- log2f .getArgument ( 0 ) = fabsf and
80
+ log2 .getTarget ( ) .hasGlobalOrStdName ( "log2" + [ "" , "l" , "f" ] ) and
81
+ fabs .getTarget ( ) .hasGlobalOrStdName ( "fabs" + [ "" , "l" , "f" ] ) and
82
+ log2 .getArgument ( 0 ) = fabs and
83
83
// Precision is either a macro expansion or function call
84
84
(
85
85
precision .( FunctionCall ) .getTarget ( ) instanceof PopCount
86
86
or
87
87
precision = any ( PrecisionMacro pm ) .getAnInvocation ( ) .getExpr ( )
88
88
) and
89
- gc .ensuresLt ( precision , log2f , 0 , c .getExpr ( ) .getBasicBlock ( ) , false )
89
+ gc .ensuresLt ( precision , log2 , 0 , c .getExpr ( ) .getBasicBlock ( ) , false )
90
90
)
91
91
)
92
92
select c , "Conversion of float to integer without appropriate guards avoiding undefined behavior."
0 commit comments