Author: steveire Date: Tue Jan 15 12:41:37 2019 New Revision: 351239 URL: http://llvm.org/viewvc/llvm-project?rev=351239&view=rev Log: Implement BlockDecl::Capture dump in terms of visitors
Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56709 Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/TextNodeDumper.cpp Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351239&r1=351238&r2=351239&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/TextNodeDumper.h (original) +++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 12:41:37 2019 @@ -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); Modified: cfe/trunk/lib/AST/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351239&r1=351238&r2=351239&view=diff ============================================================================== --- cfe/trunk/lib/AST/ASTDumper.cpp (original) +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 12:41:37 2019 @@ -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::VisitObjCPropertyImplDec 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 Blo 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()); } Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351239&r1=351238&r2=351239&view=diff ============================================================================== --- cfe/trunk/lib/AST/TextNodeDumper.cpp (original) +++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 12:41:37 2019 @@ -272,6 +272,18 @@ void TextNodeDumper::Visit(const CXXCtor } } +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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits