@@ -120,6 +120,19 @@ class CanonicalIntegerTypes extends NumericType, IntegralType {
120120 CanonicalIntegerTypes ( ) { this = this .getCanonicalArithmeticType ( ) }
121121}
122122
123+ FunctionType getExprCallFunctionType ( ExprCall call ) {
124+ // A standard expression call
125+ // Returns a FunctionPointerIshType
126+ result = call .( ExprCall ) .getExpr ( ) .getType ( )
127+ or
128+ // An expression call using the pointer to member operator (.* or ->*)
129+ // This special handling is required because we don't have a CodeQL class representing the call
130+ // to a pointer to member function, but the right hand side is extracted as the -1 child of the
131+ // call.
132+ // Returns a RoutineType
133+ result = call .( ExprCall ) .getChild ( - 1 ) .getType ( ) .( PointerToMemberType ) .getBaseType ( )
134+ }
135+
123136predicate isAssignment ( Expr source , NumericType targetType , string context ) {
124137 exists ( Expr preConversionAssignment |
125138 isPreConversionAssignment ( preConversionAssignment , targetType , context ) and
@@ -181,27 +194,16 @@ predicate isPreConversionAssignment(Expr source, NumericType targetType, string
181194 not targetType .stripTopLevelSpecifiers ( ) instanceof ReferenceType and
182195 context = "function argument"
183196 |
197+ // A regular function call
184198 targetType = call .getTarget ( ) .getParameter ( i ) .getType ( )
185199 or
186- // Handle varargs - use the fully converted type of the argument
200+ // A function call where the argument is passed as varargs
187201 call .getTarget ( ) .getNumberOfParameters ( ) <= i and
202+ // The rule states that the type should match the "adjusted" type of the argument
188203 targetType = source .getFullyConverted ( ) .getType ( )
189204 or
190- // A standard expression call
191- targetType = call .( ExprCall ) .getExpr ( ) .getType ( ) .( FunctionPointerIshType ) .getParameterType ( i )
192- or
193- // An expression call using the pointer to member operator (.* or ->*)
194- // This special handling is required because we don't have a CodeQL class representing the call
195- // to a pointer to member function, but the right hand side is extracted as the -1 child of the
196- // call
197- targetType =
198- call .( ExprCall )
199- .getChild ( - 1 )
200- .getType ( )
201- .( PointerToMemberType )
202- .getBaseType ( )
203- .( RoutineType )
204- .getParameterType ( i )
205+ // An expression call - get the function type, then the parameter type
206+ targetType = getExprCallFunctionType ( call ) .getParameterType ( i )
205207 )
206208 or
207209 // Return statement
0 commit comments