aboutsummaryrefslogtreecommitdiff
path: root/clang/include
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-01-14 17:16:00 +0000
committerSam McCall <sam.mccall@gmail.com>2019-01-14 17:16:00 +0000
commit32ef52063c207054911a9e0435cc85330faf2ee3 (patch)
treec0f040746821f3f9da48160aa85cccb23c0ada4b /clang/include
parent3badfe74a20c5b5c7a81791cd6a68c5dd4b417a7 (diff)
[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
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/RecursiveASTVisitor.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h
index 96f3d24c6db8..44aba6355758 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1368,9 +1368,14 @@ DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
template <typename Derived>
bool RecursiveASTVisitor<Derived>::canIgnoreChildDeclWhileTraversingDeclContext(
const Decl *Child) {
- // BlockDecls and CapturedDecls are traversed through BlockExprs and
- // CapturedStmts respectively.
- return isa<BlockDecl>(Child) || isa<CapturedDecl>(Child);
+ // BlockDecls are traversed through BlockExprs,
+ // CapturedDecls are traversed through CapturedStmts.
+ if (isa<BlockDecl>(Child) || isa<CapturedDecl>(Child))
+ return true;
+ // Lambda classes are traversed through LambdaExprs.
+ if (const CXXRecordDecl* Cls = dyn_cast<CXXRecordDecl>(Child))
+ return Cls->isLambda();
+ return false;
}
template <typename Derived>