This is an archive of the discontinued LLVM Phabricator instance.

[Index] Index declarations in lambda expression.
ClosedPublic

Authored by hokein on Dec 7 2018, 7:44 AM.

Diff Detail

Repository
rC Clang

Event Timeline

hokein created this revision.Dec 7 2018, 7:44 AM

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?

hokein updated this revision to Diff 178437.Dec 17 2018, 2:53 AM

Update the patch, add comments.

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.

hokein updated this revision to Diff 178660.Dec 18 2018, 6:33 AM

Update the patch.

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.

ilya-biryukov accepted this revision.Dec 18 2018, 6:51 AM

LGTM

lib/Index/IndexBody.cpp
464

NIT: remove braces around single-statement branch

This revision is now accepted and ready to land.Dec 18 2018, 6:51 AM
hokein updated this revision to Diff 178687.Dec 18 2018, 8:25 AM

Rebase and simplify the test.

hokein updated this revision to Diff 178688.Dec 18 2018, 8:27 AM
hokein marked an inline comment as done.

Fix a nit.

This revision was automatically updated to reflect the committed changes.