[PATCH] D56709: Implement BlockDecl::Capture dump in terms of visitors

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 15 01:43:52 PST 2019


steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56709

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


Index: lib/AST/TextNodeDumper.cpp
===================================================================
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -272,6 +272,18 @@
   }
 }
 
+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);
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -283,6 +283,7 @@
     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,11 @@
   NodeDumper.dumpDeclRef(D->getPropertyIvarDecl());
 }
 
+void ASTDumper::Visit(const BlockDecl::Capture &C) {
+  if (C.hasCopyExpr())
+    dumpStmt(C.getCopyExpr());
+}
+
 void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
   for (auto I : D->parameters())
     dumpDecl(I);
@@ -1383,17 +1389,8 @@
 
   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());
+      NodeDumper.Visit(I);
+      Visit(I);
     });
   }
   dumpStmt(D->getBody());
Index: include/clang/AST/TextNodeDumper.h
===================================================================
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -171,6 +171,8 @@
 
   void Visit(const OMPClause *C);
 
+  void Visit(const BlockDecl::Capture &C);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56709.181743.patch
Type: text/x-patch
Size: 2231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190115/e04282e1/attachment.bin>


More information about the cfe-commits mailing list