Closed Bug 1833548 Opened 3 years ago Closed 1 year ago

Perform heuristic filtering on overload sets in heuristic symbol resolution results

Categories

(Webtools :: Searchfox, enhancement)

enhancement

Tracking

(firefox135 fixed)

RESOLVED FIXED
Tracking Status
firefox135 --- fixed

People

(Reporter: botond, Assigned: nicolas.guichard)

References

(Blocks 1 open bug)

Details

Attachments

(3 external files)

In bug 1781178, I'm adding logic to MozsearchIndexer to heuristically resolve some symbols in template definitions based on analysis of the uninstantiated template body (in addition to existing logic to analyze instantiations and produce concrete results from that).

The heuristics sometimes result in overload sets. These can arise in the following places:

The current behaviour is to just retain all overloads. However, we can in some cases do better by using information about the call site (i.e. the arguments) to filter out overloads that we can rule out as being even potential results.

The following strategies come to mind, from easiest to hardest:

  • Filter by arity. In most cases, we know the number of arguments in the call and the number of parameters a candidate has, and if they don't match (modulo default arguments), we can discard the candidate. (If parameter packs are involved, we don't know the exact number of arguments or parameters, but we have a lower bound and may still be able to rule out a match in some cases.)
  • If the arguments are not dependent (this can happen if e.g. the call has the form x.foo(args), and x is dependent, but heuristic resolution of x yields a concrete type, and args are not dependent), we may be able to coax clang into running its actual overload resolution algorithm implementation on the overload set, and get an accurate result.
  • If the arguments are dependent, trying to run clang's overload resolution algorithm implementation is probably out of the question, however we may be able to implement heuristics that handle common cases. For example, if there are two overloads with signatures (A<T>) and (B<T>), and the argument has type A<U> (where A and B are concrete templates, and T and U are template parameters), we know the first overload will be the match even though the argument type is dependent.
Blocks: 1905433
Attached file GitHub Pull Request —
Assignee: nobody → nicolas.guichard
Status: NEW → ASSIGNED

This updates the Mozsearch Clang plugin with this upstream change meant
to emit structured information for variables which aren't field:
https://github.com/mozsearch/mozsearch/pull/845

This implements the first strategy proposed by Botond to filter
unresolved overload sets: by arity.

We don't have easy access to the CallExpr from OverloadExpr,
CXXDependentScopeMemberExpr or DependentScopeDeclRefExpr, so we add
tracking for that in TraverseCallExpr.

This was previously reviewed upstream on GitHub:
https://github.com/mozsearch/mozsearch/pull/851

Pushed by nicolas.guichard@kdab.com: https://hg.mozilla.org/integration/autoland/rev/ff5c409fae82 Mozsearch Clang plugin update. r=asuth https://hg.mozilla.org/integration/autoland/rev/dac00f47e372 Filter template heuristic candidates by call arity. r=asuth
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: