/// \brief Recursively visit a lambda capture.
///
/// \returns false if the visitation was terminated early, true otherwise.
- bool TraverseLambdaCapture(LambdaCapture C);
+ bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C);
+
+ /// \brief Recursively visit the body of a lambda expression.
+ ///
+ /// This provides a hook for visitors that need more context when visiting
+ /// \c LE->getBody().
+ ///
+ /// \returns false if the visitation was terminated early, true otherwise.
+ bool TraverseLambdaBody(LambdaExpr *LE);
// ---- Methods on Attrs ----
}
template <typename Derived>
-bool RecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaCapture C) {
+bool
+RecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaExpr *LE,
+ const LambdaCapture *C) {
+ if (C->isInitCapture())
+ TRY_TO(TraverseDecl(C->getCapturedVar()));
+ return true;
+}
+
+template <typename Derived>
+bool RecursiveASTVisitor<Derived>::TraverseLambdaBody(LambdaExpr *LE) {
+ StmtQueueAction StmtQueue(*this);
+ StmtQueue.queue(LE->getBody());
return true;
}
for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
CEnd = S->explicit_capture_end();
C != CEnd; ++C) {
- TRY_TO(TraverseLambdaCapture(*C));
+ TRY_TO(TraverseLambdaCapture(S, C));
}
if (S->hasExplicitParameters() || S->hasExplicitResultType()) {
}
}
- StmtQueueAction StmtQueue(*this);
- StmtQueue.queue(S->getBody());
+ TRY_TO(TraverseLambdaBody(S));
return true;
}
return true;
}
- bool TraverseLambdaCapture(LambdaCapture C) {
- if (C.capturesThis())
+ bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C) {
+ if (C->capturesThis())
return true;
- if (C.capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
- IndexCtx.handleReference(C.getCapturedVar(), C.getLocation(),
- Parent, ParentDC);
+ if (C->capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
+ IndexCtx.handleReference(C->getCapturedVar(), C->getLocation(), Parent,
+ ParentDC);
// FIXME: Lambda init-captures.
return true;