summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTDumper.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2018-12-09 13:30:17 +0000
committerStephen Kelly <steveire@gmail.com>2018-12-09 13:30:17 +0000
commite26a88aaa870383bb3467bc2df1924619d3147c7 (patch)
treeb9adda3a855f6052ec1829c1c8714f6faa5717a4 /clang/lib/AST/ASTDumper.cpp
parent50a29bd40b5198336170971a5c274707962d182d (diff)
downloadbcm5719-llvm-e26a88aaa870383bb3467bc2df1924619d3147c7.tar.gz
bcm5719-llvm-e26a88aaa870383bb3467bc2df1924619d3147c7.zip
NFC: Move dump of individual comment nodes to NodeDumper
Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55190 llvm-svn: 348719
Diffstat (limited to 'clang/lib/AST/ASTDumper.cpp')
-rw-r--r--clang/lib/AST/ASTDumper.cpp154
1 files changed, 2 insertions, 152 deletions
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index b95813ed7c1..353d29cde7b 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -48,7 +48,6 @@ namespace {
TextNodeDumper NodeDumper;
raw_ostream &OS;
- const CommandTraits *Traits;
/// The policy to use for printing; can be defaulted.
PrintingPolicy PrintPolicy;
@@ -77,7 +76,7 @@ namespace {
const SourceManager *SM, bool ShowColors,
const PrintingPolicy &PrintPolicy)
: TreeStructure(OS, ShowColors),
- NodeDumper(OS, ShowColors, SM, PrintPolicy), OS(OS), Traits(Traits),
+ NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
PrintPolicy(PrintPolicy), ShowColors(ShowColors) {}
void setDeserialize(bool D) { Deserialize = D; }
@@ -433,31 +432,7 @@ namespace {
void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
// Comments.
- const char *getCommandName(unsigned CommandID);
void dumpComment(const Comment *C, const FullComment *FC);
-
- // Inline comments.
- void visitTextComment(const TextComment *C, const FullComment *FC);
- void visitInlineCommandComment(const InlineCommandComment *C,
- const FullComment *FC);
- void visitHTMLStartTagComment(const HTMLStartTagComment *C,
- const FullComment *FC);
- void visitHTMLEndTagComment(const HTMLEndTagComment *C,
- const FullComment *FC);
-
- // Block comments.
- void visitBlockCommandComment(const BlockCommandComment *C,
- const FullComment *FC);
- void visitParamCommandComment(const ParamCommandComment *C,
- const FullComment *FC);
- void visitTParamCommandComment(const TParamCommandComment *C,
- const FullComment *FC);
- void visitVerbatimBlockComment(const VerbatimBlockComment *C,
- const FullComment *FC);
- void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C,
- const FullComment *FC);
- void visitVerbatimLineComment(const VerbatimLineComment *C,
- const FullComment *FC);
};
}
@@ -2289,29 +2264,12 @@ void ASTDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) {
// Comments
//===----------------------------------------------------------------------===//
-const char *ASTDumper::getCommandName(unsigned CommandID) {
- if (Traits)
- return Traits->getCommandInfo(CommandID)->Name;
- const CommandInfo *Info = CommandTraits::getBuiltinCommandInfo(CommandID);
- if (Info)
- return Info->Name;
- return "<not a builtin command>";
-}
-
void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
dumpChild([=] {
+ NodeDumper.Visit(C, FC);
if (!C) {
- ColorScope Color(OS, ShowColors, NullColor);
- OS << "<<<NULL>>>";
return;
}
-
- {
- ColorScope Color(OS, ShowColors, CommentColor);
- OS << C->getCommentKindName();
- }
- NodeDumper.dumpPointer(C);
- NodeDumper.dumpSourceRange(C->getSourceRange());
ConstCommentVisitor<ASTDumper, void, const FullComment *>::visit(C, FC);
for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
I != E; ++I)
@@ -2319,114 +2277,6 @@ void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
});
}
-void ASTDumper::visitTextComment(const TextComment *C, const FullComment *) {
- OS << " Text=\"" << C->getText() << "\"";
-}
-
-void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C,
- const FullComment *) {
- OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
- switch (C->getRenderKind()) {
- case InlineCommandComment::RenderNormal:
- OS << " RenderNormal";
- break;
- case InlineCommandComment::RenderBold:
- OS << " RenderBold";
- break;
- case InlineCommandComment::RenderMonospaced:
- OS << " RenderMonospaced";
- break;
- case InlineCommandComment::RenderEmphasized:
- OS << " RenderEmphasized";
- break;
- }
-
- for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
- OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
-}
-
-void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C,
- const FullComment *) {
- OS << " Name=\"" << C->getTagName() << "\"";
- if (C->getNumAttrs() != 0) {
- OS << " Attrs: ";
- for (unsigned i = 0, e = C->getNumAttrs(); i != e; ++i) {
- const HTMLStartTagComment::Attribute &Attr = C->getAttr(i);
- OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
- }
- }
- if (C->isSelfClosing())
- OS << " SelfClosing";
-}
-
-void ASTDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C,
- const FullComment *) {
- OS << " Name=\"" << C->getTagName() << "\"";
-}
-
-void ASTDumper::visitBlockCommandComment(const BlockCommandComment *C,
- const FullComment *) {
- OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
- for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
- OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
-}
-
-void ASTDumper::visitParamCommandComment(const ParamCommandComment *C,
- const FullComment *FC) {
- OS << " " << ParamCommandComment::getDirectionAsString(C->getDirection());
-
- if (C->isDirectionExplicit())
- OS << " explicitly";
- else
- OS << " implicitly";
-
- if (C->hasParamName()) {
- if (C->isParamIndexValid())
- OS << " Param=\"" << C->getParamName(FC) << "\"";
- else
- OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
- }
-
- if (C->isParamIndexValid() && !C->isVarArgParam())
- OS << " ParamIndex=" << C->getParamIndex();
-}
-
-void ASTDumper::visitTParamCommandComment(const TParamCommandComment *C,
- const FullComment *FC) {
- if (C->hasParamName()) {
- if (C->isPositionValid())
- OS << " Param=\"" << C->getParamName(FC) << "\"";
- else
- OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
- }
-
- if (C->isPositionValid()) {
- OS << " Position=<";
- for (unsigned i = 0, e = C->getDepth(); i != e; ++i) {
- OS << C->getIndex(i);
- if (i != e - 1)
- OS << ", ";
- }
- OS << ">";
- }
-}
-
-void ASTDumper::visitVerbatimBlockComment(const VerbatimBlockComment *C,
- const FullComment *) {
- OS << " Name=\"" << getCommandName(C->getCommandID()) << "\""
- " CloseName=\"" << C->getCloseName() << "\"";
-}
-
-void ASTDumper::visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C,
- const FullComment *) {
- OS << " Text=\"" << C->getText() << "\"";
-}
-
-void ASTDumper::visitVerbatimLineComment(const VerbatimLineComment *C,
- const FullComment *) {
- OS << " Text=\"" << C->getText() << "\"";
-}
-
//===----------------------------------------------------------------------===//
// Type method implementations
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud