summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTDumper.cpp27
-rw-r--r--clang/lib/AST/TextNodeDumper.cpp23
2 files changed, 31 insertions, 19 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 91ca716bade..93df02d7f6c 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 @@ namespace {
: 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 @@ namespace {
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 @@ namespace {
// 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::dumpLookups(const DeclContext *DC, bool DumpDecls) {
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 3598e286807..2a240412a29 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -41,6 +41,29 @@ void TextNodeDumper::Visit(const comments::Comment *C,
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;
OpenPOWER on IntegriCloud