This is an archive of the discontinued LLVM Phabricator instance.

[AST] Unify the code paths of traversing lambda expressions.
ClosedPublic

Authored by hokein on Dec 18 2018, 6:19 AM.

Details

Summary

This supposes to be a non-functional change. We have two code paths when
traversing lambda expressions:

  1. traverse the function proto typeloc when parameters and return type

are explicit;

  1. otherwise fallback to traverse parameter decls and return type loc

individually;

This patch unifies the code path to always traverse parameters and
return type, rather than relying on traversing the full type-loc.

Diff Detail

Event Timeline

hokein created this revision.Dec 18 2018, 6:19 AM
ilya-biryukov added inline comments.Dec 18 2018, 6:46 AM
include/clang/AST/RecursiveASTVisitor.h
2416

Could we add a comment on why we can't simply call the TraverseTypeLoc here?
Something like:

/// We manually deconstruct the TypeLoc for the lambda type to only
/// visit the parts of the type that were explicitly specified. 
/// We do not call the `TraverseTypeLoc` function to make sure we 
/// visit explicitly specified parts of the lambda even when shouldWalkTypeOfTypeLocs()
/// return false.
hokein updated this revision to Diff 178667.Dec 18 2018, 7:06 AM
hokein marked an inline comment as done.

Fix the format.

hokein added inline comments.Dec 18 2018, 7:06 AM
include/clang/AST/RecursiveASTVisitor.h
2416

As discussed, this patch is just to simplify the code, this comment is not needed.

ilya-biryukov accepted this revision.Dec 18 2018, 7:23 AM

LGTM. The new code looks simpler and it's arguably simpler for the clients, since they'll have a consistent set of callbacks independent of the actual view into the lambda expression.

include/clang/AST/RecursiveASTVisitor.h
2416

Thanks for clarifying, I had incorrect assumptions about the reasons for the original failure in the index library.

This revision is now accepted and ready to land.Dec 18 2018, 7:23 AM
This revision was automatically updated to reflect the committed changes.