diff options
author | Stephen Kelly <steveire@gmail.com> | 2019-01-15 20:31:31 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2019-01-15 20:31:31 +0000 |
commit | 5d4c9d6ad9589a0956d62ecae184fcd8ae8ae832 (patch) | |
tree | 8a6e08cf8781dbf261f2ab7bab5933d524ea9609 | |
parent | 484e44a17e3b2e69eb22c5f5f50a7038965745c4 (diff) |
NFC: Implement OMPClause dump in terms of visitors
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D56708
-rw-r--r-- | clang/include/clang/AST/TextNodeDumper.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/ASTDumper.cpp | 32 | ||||
-rw-r--r-- | clang/lib/AST/TextNodeDumper.cpp | 18 |
3 files changed, 31 insertions, 21 deletions
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index a5cc47f00b6..63200284471 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -169,6 +169,8 @@ public: void Visit(const CXXCtorInitializer *Init); + void Visit(const OMPClause *C); + void dumpPointer(const void *Ptr); void dumpLocation(SourceLocation Loc); void dumpSourceRange(SourceRange R); diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index 49774aabdfb..26e2f64d221 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -292,6 +292,7 @@ namespace { void VisitCapturedStmt(const CapturedStmt *Node); // OpenMP + void Visit(const OMPClause *C); void VisitOMPExecutableDirective(const OMPExecutableDirective *Node); // Exprs @@ -1448,29 +1449,18 @@ void ASTDumper::VisitCapturedStmt(const CapturedStmt *Node) { // OpenMP dumping methods. //===----------------------------------------------------------------------===// +void ASTDumper::Visit(const OMPClause *C) { + dumpChild([=] { + NodeDumper.Visit(C); + for (auto *S : C->children()) + dumpStmt(S); + }); +} + void ASTDumper::VisitOMPExecutableDirective( const OMPExecutableDirective *Node) { - for (auto *C : Node->clauses()) { - dumpChild([=] { - if (!C) { - ColorScope Color(OS, ShowColors, NullColor); - OS << "<<<NULL>>> OMPClause"; - return; - } - { - ColorScope Color(OS, ShowColors, AttrColor); - StringRef ClauseName(getOpenMPClauseName(C->getClauseKind())); - OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper() - << ClauseName.drop_front() << "Clause"; - } - NodeDumper.dumpPointer(C); - NodeDumper.dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc())); - if (C->isImplicit()) - OS << " <implicit>"; - for (auto *S : C->children()) - dumpStmt(S); - }); - } + for (const auto *C : Node->clauses()) + Visit(C); } //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 97fcaba2c97..c20e55ee8a0 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -272,6 +272,24 @@ void TextNodeDumper::Visit(const CXXCtorInitializer *Init) { } } +void TextNodeDumper::Visit(const OMPClause *C) { + if (!C) { + ColorScope Color(OS, ShowColors, NullColor); + OS << "<<<NULL>>> OMPClause"; + return; + } + { + ColorScope Color(OS, ShowColors, AttrColor); + StringRef ClauseName(getOpenMPClauseName(C->getClauseKind())); + OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper() + << ClauseName.drop_front() << "Clause"; + } + dumpPointer(C); + dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc())); + if (C->isImplicit()) + OS << " <implicit>"; +} + void TextNodeDumper::dumpPointer(const void *Ptr) { ColorScope Color(OS, ShowColors, AddressColor); OS << ' ' << Ptr; |