]> granicus.if.org Git - clang/commit
[AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.
authorSam McCall <sam.mccall@gmail.com>
Mon, 14 Jan 2019 10:31:42 +0000 (10:31 +0000)
committerSam McCall <sam.mccall@gmail.com>
Mon, 14 Jan 2019 10:31:42 +0000 (10:31 +0000)
commit765aed95548bbd215d97f8418f43815823e79905
tree74df789599c43aa40aea18afd5650f5ae4ecc53d
parente593a791f2cf19db84237b0b9d632e9966a00a39
[AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

Summary:
This fixes ASTContext's parent map for nodes in such classes (e.g. operator()).
https://bugs.llvm.org/show_bug.cgi?id=39949

This also changes the observed shape of the AST for implicit RAVs.
- this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes,
functionDecl() matches the call operator, and the parent chain is body -> call
operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr.
- this appears not to matter for the ASTImporterLookupTable builder
- this doesn't matter for the other RAVs in-tree.

In order to do this, we remove the TraverseLambdaBody hook. The problem is it's
hard/weird to ensure this hook is called when traversing via the implicit class.
There were just two users of this hook in-tree, who use it to skip bodies.
I replaced these with explicitly traversing the captures only. Another approach
would be recording the bodies when the lambda is visited, and then recognizing
them later.
I'd be open to suggestion on how to preserve this hook, instead.

Reviewers: aaron.ballman, JonasToth

Subscribers: cfe-commits, rsmith, jdennett

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351047 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/RecursiveASTVisitor.h
lib/CodeGen/CodeGenPGO.cpp
lib/Sema/AnalysisBasedWarnings.cpp
unittests/AST/ASTContextParentMapTest.cpp
unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp