]> granicus.if.org Git - clang/commitdiff
Implement BlockDecl::Capture dump in terms of visitors
authorStephen Kelly <steveire@gmail.com>
Tue, 15 Jan 2019 20:41:37 +0000 (20:41 +0000)
committerStephen Kelly <steveire@gmail.com>
Tue, 15 Jan 2019 20:41:37 +0000 (20:41 +0000)
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

include/clang/AST/TextNodeDumper.h
lib/AST/ASTDumper.cpp
lib/AST/TextNodeDumper.cpp

index 63200284471e156566fe462a394b0022c272a321..7940663763000a96f61c19f701a7030e2b832418 100644 (file)
@@ -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);
index 26e2f64d221e67e7ec225e31c9eae4138b801d6d..852b72897606bbd568e3e5d9f9e27547f73ae22d 100644 (file)
@@ -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());
 }
 
index c20e55ee8a086539ad6baa2feac45e6bbc3b325c..b51a9006226ae65b4d5eeb1f427f5f42f6b2c4a0 100644 (file)
@@ -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);