@@ -123,34 +123,37 @@ int getMinimumNumberOfParameters(Function f) {
123123 result = count ( Parameter p | p = f .getAParameter ( ) and not p .hasInitializer ( ) | p )
124124}
125125
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 ) {
128128 (
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 ) |
129141 // Call through function pointer
130142 call instanceof ExprCall
131143 or
132144 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+ )
154157 )
155158 )
156159}
0 commit comments