r351236 - NFC: Implement OMPClause dump in terms of visitors

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 15 12:31:31 PST 2019


Author: steveire
Date: Tue Jan 15 12:31:31 2019
New Revision: 351236

URL: http://llvm.org/viewvc/llvm-project?rev=351236&view=rev
Log:
NFC: Implement OMPClause dump in terms of visitors

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56708

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=351236&r1=351235&r2=351236&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 15 12:31:31 2019
@@ -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);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351236&r1=351235&r2=351236&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 15 12:31:31 2019
@@ -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
 //  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);
 }
 
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351236&r1=351235&r2=351236&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 15 12:31:31 2019
@@ -272,6 +272,24 @@ void TextNodeDumper::Visit(const CXXCtor
   }
 }
 
+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;




More information about the cfe-commits mailing list