summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2019-01-15 20:41:37 +0000
committerStephen Kelly <steveire@gmail.com>2019-01-15 20:41:37 +0000
commit48f3908b008d2b24ee43e9e8e3ce66c37b92baf3 (patch)
tree9f4359468a01d84d61b584b0de905d3ce84b564b
parentfb4e678d5a81330b77c5dcd5de0aea025be8a196 (diff)
Implement BlockDecl::Capture dump in terms of visitors
Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56709 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351239 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/TextNodeDumper.h2
-rw-r--r--lib/AST/ASTDumper.cpp26
-rw-r--r--lib/AST/TextNodeDumper.cpp12
3 files changed, 25 insertions, 15 deletions
diff --git a/include/clang/AST/TextNodeDumper.h b/include/clang/AST/TextNodeDumper.h
index 6320028447..7940663763 100644
--- a/include/clang/AST/TextNodeDumper.h
+++ b/include/clang/AST/TextNodeDumper.h
@@ -171,6 +171,8 @@ public:
void Visit(const OMPClause *C);
+ void Visit(const BlockDecl::Capture &C);
+
void dumpPointer(const void *Ptr);
void dumpLocation(SourceLocation Loc);
void dumpSourceRange(SourceRange R);
diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp
index 26e2f64d22..852b728976 100644
--- a/lib/AST/ASTDumper.cpp
+++ b/lib/AST/ASTDumper.cpp
@@ -283,6 +283,7 @@ namespace {
void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
+ void Visit(const BlockDecl::Capture &C);
void VisitBlockDecl(const BlockDecl *D);
// Stmts.
@@ -1371,6 +1372,14 @@ void ASTDumper::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
NodeDumper.dumpDeclRef(D->getPropertyIvarDecl());
}
+void ASTDumper::Visit(const BlockDecl::Capture &C) {
+ dumpChild([=] {
+ NodeDumper.Visit(C);
+ if (C.hasCopyExpr())
+ dumpStmt(C.getCopyExpr());
+ });
+}
+
void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
for (auto I : D->parameters())
dumpDecl(I);
@@ -1381,21 +1390,8 @@ void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
if (D->capturesCXXThis())
dumpChild([=]{ OS << "capture this"; });
- for (const auto &I : D->captures()) {
- dumpChild([=] {
- OS << "capture";
- if (I.isByRef())
- OS << " byref";
- if (I.isNested())
- OS << " nested";
- if (I.getVariable()) {
- OS << ' ';
- NodeDumper.dumpBareDeclRef(I.getVariable());
- }
- if (I.hasCopyExpr())
- dumpStmt(I.getCopyExpr());
- });
- }
+ for (const auto &I : D->captures())
+ Visit(I);
dumpStmt(D->getBody());
}
diff --git a/lib/AST/TextNodeDumper.cpp b/lib/AST/TextNodeDumper.cpp
index c20e55ee8a..b51a900622 100644
--- a/lib/AST/TextNodeDumper.cpp
+++ b/lib/AST/TextNodeDumper.cpp
@@ -272,6 +272,18 @@ void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
}
}
+void TextNodeDumper::Visit(const BlockDecl::Capture &C) {
+ OS << "capture";
+ if (C.isByRef())
+ OS << " byref";
+ if (C.isNested())
+ OS << " nested";
+ if (C.getVariable()) {
+ OS << ' ';
+ dumpBareDeclRef(C.getVariable());
+ }
+}
+
void TextNodeDumper::Visit(const OMPClause *C) {
if (!C) {
ColorScope Color(OS, ShowColors, NullColor);