Implement Attr dumping in terms of visitors

Remove now-vestigial dumpType and dumpBareDeclRef methods. The old
tablegen generated code used to expect them to be present, but the new
generated code has no such requirement.

Reviewers: aaron.ballman

Subscribers: mgorny, cfe-commits

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

llvm-svn: 350958
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 91ca716..93df02d 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDumperUtils.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/AttrVisitor.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclLookups.h"
@@ -42,7 +43,8 @@
       : public ConstDeclVisitor<ASTDumper>,
         public ConstStmtVisitor<ASTDumper>,
         public ConstCommentVisitor<ASTDumper, void, const FullComment *>,
-        public TypeVisitor<ASTDumper> {
+        public TypeVisitor<ASTDumper>,
+        public ConstAttrVisitor<ASTDumper> {
 
     TextNodeDumper NodeDumper;
 
@@ -86,10 +88,8 @@
     void dumpStmt(const Stmt *S, StringRef Label = {});
 
     // Utilities
-    void dumpType(QualType T) { NodeDumper.dumpType(T); }
     void dumpTypeAsChild(QualType T);
     void dumpTypeAsChild(const Type *T);
-    void dumpBareDeclRef(const Decl *Node) { NodeDumper.dumpBareDeclRef(Node); }
     void dumpDeclContext(const DeclContext *DC);
     void dumpLookups(const DeclContext *DC, bool DumpDecls);
     void dumpAttr(const Attr *A);
@@ -439,6 +439,9 @@
 
     // Comments.
     void dumpComment(const Comment *C, const FullComment *FC);
+
+// Implements Visit methods for Attrs.
+#include "clang/AST/AttrNodeTraverse.inc"
   };
 }
 
@@ -584,22 +587,8 @@
 
 void ASTDumper::dumpAttr(const Attr *A) {
   dumpChild([=] {
-    {
-      ColorScope Color(OS, ShowColors, AttrColor);
-
-      switch (A->getKind()) {
-#define ATTR(X) case attr::X: OS << #X; break;
-#include "clang/Basic/AttrList.inc"
-      }
-      OS << "Attr";
-    }
-    NodeDumper.dumpPointer(A);
-    NodeDumper.dumpSourceRange(A->getRange());
-    if (A->isInherited())
-      OS << " Inherited";
-    if (A->isImplicit())
-      OS << " Implicit";
-#include "clang/AST/AttrDump.inc"
+    NodeDumper.Visit(A);
+    ConstAttrVisitor<ASTDumper>::Visit(A);
   });
 }
 
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 3598e28..2a24041 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -41,6 +41,29 @@
                       const comments::FullComment *>::visit(C, FC);
 }
 
+void TextNodeDumper::Visit(const Attr *A) {
+  {
+    ColorScope Color(OS, ShowColors, AttrColor);
+
+    switch (A->getKind()) {
+#define ATTR(X)                                                                \
+  case attr::X:                                                                \
+    OS << #X;                                                                  \
+    break;
+#include "clang/Basic/AttrList.inc"
+    }
+    OS << "Attr";
+  }
+  dumpPointer(A);
+  dumpSourceRange(A->getRange());
+  if (A->isInherited())
+    OS << " Inherited";
+  if (A->isImplicit())
+    OS << " Implicit";
+
+  ConstAttrVisitor<TextNodeDumper>::Visit(A);
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;