This fixes clangd couldn't find references for lambda parameters.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
The RecursiveASTVisitor seems to have the code that properly traverses parameters and return types of lambdas. Any ideas why it's not getting called here?
Update after investigating with @hokein offline: the RecursiveASTVisitor has custom code to visit lambda parameters and return type, but it fallback to visiting typelocs when both parameters and a return type are specified. Unfortunately this fallback does not work when shouldWalkTypeLocs() is set to false, which is the case for our visitor out here.
It seems reasonable to always visit parameters and return type, rather than relying on traversing the full type-loc of the lamda's function type.
Thanks! After taking a look at the code closely, it turns out VisitTypeLoc callback gets called when shouldWalkTypeOfTypeLocs is set to false, shouldWalkTypeOfTypeLocs just controls whether we visit the type itself, type loc is always visited.
Unifying code paths of RecursiveASTVisitor seems fine to me, and also simplifies the code of client side, separated in D55820.
NIT: remove braces around single-statement branch