@@ -123,34 +123,37 @@ int getMinimumNumberOfParameters(Function f) {
123
123
result = count ( Parameter p | p = f .getAParameter ( ) and not p .hasInitializer ( ) | p )
124
124
}
125
125
126
- predicate isOverloadIndependent ( Call call , Expr arg ) {
127
- arg = call . getAnArgument ( ) and
126
+ /** Get an overload of the function f, excluding deleted overloads. */
127
+ Function getAnOverload ( Function f ) {
128
128
(
129
+ result = f .getAnOverload ( )
130
+ or
131
+ // Instantiated function templates don't directly participate in overload resolution
132
+ // so check the templates overloads
133
+ result = f .( FunctionTemplateInstantiation ) .getTemplate ( ) .getAnOverload ( )
134
+ ) and
135
+ // Exclude deleted overloads
136
+ not result .isDeleted ( )
137
+ }
138
+
139
+ predicate isOverloadIndependent ( Call call , Expr arg ) {
140
+ exists ( int i | arg = call .getArgument ( i ) |
129
141
// Call through function pointer
130
142
call instanceof ExprCall
131
143
or
132
144
isNonExtensible ( call ) and
133
- forall ( Function target , Function overload , int i |
134
- target = call .getTarget ( ) and
135
- (
136
- overload = target .getAnOverload ( )
137
- or
138
- // Instantiated function templates don't directly participate in overload resolution
139
- // so check the templates overloads
140
- overload = target .( FunctionTemplateInstantiation ) .getTemplate ( ) .getAnOverload ( )
141
- ) and
142
- // Check that the overload accepts the number of arguments provided by this call,
143
- // considering parameters with default values may be omitted in the call
144
- overload .getNumberOfParameters ( ) >= call .getNumberOfArguments ( ) and
145
- getMinimumNumberOfParameters ( overload ) <= call .getNumberOfArguments ( ) and
146
- // Ignore deleted overloads
147
- not overload .isDeleted ( ) and
148
- //
149
- call .getArgument ( i ) = arg
150
- |
151
- // Check that the parameter types match
152
- overload .getParameter ( i ) .getType ( ) .getUnspecifiedType ( ) =
153
- target .getParameter ( i ) .getType ( ) .getUnspecifiedType ( )
145
+ exists ( Function target | target = call .getTarget ( ) |
146
+ forall ( Function overload |
147
+ overload = getAnOverload ( target ) and
148
+ // Check that the overload accepts the number of arguments provided by this call,
149
+ // considering parameters with default values may be omitted in the call
150
+ overload .getNumberOfParameters ( ) >= call .getNumberOfArguments ( ) and
151
+ getMinimumNumberOfParameters ( overload ) <= call .getNumberOfArguments ( )
152
+ |
153
+ // Check that the parameter types match
154
+ overload .getParameter ( i ) .getType ( ) .getUnspecifiedType ( ) =
155
+ target .getParameter ( i ) .getType ( ) .getUnspecifiedType ( )
156
+ )
154
157
)
155
158
)
156
159
}
0 commit comments