summaryrefslogtreecommitdiff
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-01-14 10:31:42 +0000
committerSam McCall <sam.mccall@gmail.com>2019-01-14 10:31:42 +0000
commit765aed95548bbd215d97f8418f43815823e79905 (patch)
tree74df789599c43aa40aea18afd5650f5ae4ecc53d /lib/Sema/AnalysisBasedWarnings.cpp
parente593a791f2cf19db84237b0b9d632e9966a00a39 (diff)
downloadclang-765aed95548bbd215d97f8418f43815823e79905.tar.gz
[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
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 3b6cbe9469..c818d40c77 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1153,7 +1153,12 @@ namespace {
bool TraverseDecl(Decl *D) { return true; }
// We analyze lambda bodies separately. Skip them here.
- bool TraverseLambdaBody(LambdaExpr *LE) { return true; }
+ bool TraverseLambdaExpr(LambdaExpr *LE) {
+ // Traverse the captures, but not the body.
+ for (const auto &C : zip(LE->captures(), LE->capture_inits()))
+ TraverseLambdaCapture(LE, &std::get<0>(C), std::get<1>(C));
+ return true;
+ }
private: