[AST] Fix double-traversal of code in top-level lambdas in RAV(implicit = yes).
authorSam McCall <sam.mccall@gmail.com>
Mon, 14 Jan 2019 17:16:00 +0000 (17:16 +0000)
committerSam McCall <sam.mccall@gmail.com>
Mon, 14 Jan 2019 17:16:00 +0000 (17:16 +0000)
commit32ef52063c207054911a9e0435cc85330faf2ee3
treec0f040746821f3f9da48160aa85cccb23c0ada4b
parent3badfe74a20c5b5c7a81791cd6a68c5dd4b417a7
[AST] Fix double-traversal of code in top-level lambdas in RAV(implicit = yes).

Summary:
Prior to r351069, lambda classes were traversed or not depending on the
{Function, Class, Namespace, TU} DeclContext containing them.
If it was a function (common case) they were not traversed.
If it was a namespace or TU (top-level lambda) they were traversed as part of
that DeclContext traversal.

r351069 "fixed" RAV to traverse these as part of the LambdaExpr, which is the
right place. But top-level lambdas are now traversed twice.
We fix that as blocks and block captures were apparently fixed in the past.

Maybe it would be nicer to avoid adding the lambda classes to the DeclContext
in the first place, but I can't work out the implications of that.

Reviewers: bkramer, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56665

llvm-svn: 351075
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp