This could crash when our heuristic picks the wrong function. Make sure
there is enough parameters in the candidate to prevent those crashes.
Also special case copy/move constructors to make the heuristic work in
presence of those.
Differential D130260
[clangd] Make forwarding parameter detection logic resilient kadircet on Jul 21 2022, 5:49 AM. Authored by
Details This could crash when our heuristic picks the wrong function. Make sure Also special case copy/move constructors to make the heuristic work in
Diff Detail
Event TimelineComment Actions Your approach to handling implicit conversions is much nicer than mine, so I abandoned my revision. There is still one case (that might even occur in the code base I'm working on?) that this change would lead to incorrect hints on. WDYT about keeping the other changes, but using my pack detection logic?
Comment Actions Not sure I qualify as a suitable reviewer, but this looks really good to me, save for maybe a small safety measure :)
Comment Actions driveby thoughts, but please don't block on them. (if this fix is a heuristic that fixes a common crash but isn't completely correct, that may still be worth landing but warrants a fixme)
Comment Actions The fix is not an heuristic. We just make sure we never consider a function with less parameters than the arguments we have, that way rest of the assumptions hold (we might still pick a wrong function call, as we could in the past, but we won't crash).
Comment Actions OK, but it's missing a comment that says "this is a heuristic and may not be correct, at least it won't crash"! The original code was intended to be *correct*, not a heuristic. If we're not going to fix it properly (which is reasonable in the circumstances), we need to document the limitations. |
This is not a sufficient check, since the other parameters need not be from an expanded pack.
Example:
Here we shouldn't print a hint at all, but we print x: and y:
The important distinction is between Expr(args...) and Expr(args)..., which can be decided in the instantiated case by the check I implemented in https://reviews.llvm.org/D130259 for all cases, except when args only consists of a single element.