Perform heuristic filtering on overload sets in heuristic symbol resolution results
Categories
(Webtools :: Searchfox, enhancement)
Tracking
(firefox135 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:
- In IndexConsumer::VisitOverloadExpr()
- In CXXRecordDecl::lookupDependentName(), which is called by the
HeuristicResolverimplementation (which in turn is called byIndexConsumer::VisitCXXDependentScopeMemberExpr()and possibly other places in the future)
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), andxis dependent, but heuristic resolution ofxyields a concrete type, andargsare 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 typeA<U>(whereAandBare concrete templates, andTandUare template parameters), we know the first overload will be the match even though the argument type is dependent.
| Assignee | ||
Comment 1•1 year ago
|
||
| Assignee | ||
Comment 2•1 year ago
|
||
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
| Assignee | ||
Comment 3•1 year ago
|
||
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
Comment 5•1 year ago
|
||
| bugherder | ||
Description
•