blob: 6248da045a71bbd62ad76142c973f47571ae3259 [file] [log] [blame]
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001//===--- ASTDumper.cpp - Dumping implementation for ASTs ------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner6000dac2007-08-08 22:51:59 +00007//
8//===----------------------------------------------------------------------===//
9//
Alexander Kornienko40b66a002012-12-13 13:59:55 +000010// This file implements the AST dump methods, which dump out the
Chris Lattner6000dac2007-08-08 22:51:59 +000011// AST in a form that exposes type details and other fields.
12//
13//===----------------------------------------------------------------------===//
14
Chandler Carruth55fc8732012-12-04 09:13:33 +000015#include "clang/AST/ASTContext.h"
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +000016#include "clang/AST/Attr.h"
Alexander Kornienkoacd356e2013-01-14 14:07:11 +000017#include "clang/AST/CommentVisitor.h"
Chandler Carruth55fc8732012-12-04 09:13:33 +000018#include "clang/AST/DeclCXX.h"
19#include "clang/AST/DeclObjC.h"
Alexander Kornienkod538ed92012-12-20 02:09:13 +000020#include "clang/AST/DeclVisitor.h"
Chandler Carruth55fc8732012-12-04 09:13:33 +000021#include "clang/AST/StmtVisitor.h"
Alexander Kornienkod538ed92012-12-20 02:09:13 +000022#include "clang/Basic/Module.h"
Chris Lattnere300c872007-08-30 06:17:34 +000023#include "clang/Basic/SourceManager.h"
Daniel Dunbar806c12e2009-12-03 09:13:13 +000024#include "llvm/Support/raw_ostream.h"
Chris Lattner6000dac2007-08-08 22:51:59 +000025using namespace clang;
Alexander Kornienkoacd356e2013-01-14 14:07:11 +000026using namespace clang::comments;
Chris Lattner6000dac2007-08-08 22:51:59 +000027
28//===----------------------------------------------------------------------===//
Alexander Kornienko40b66a002012-12-13 13:59:55 +000029// ASTDumper Visitor
Chris Lattner6000dac2007-08-08 22:51:59 +000030//===----------------------------------------------------------------------===//
31
32namespace {
Richard Trieu7ba443a2013-01-26 01:31:20 +000033 // Colors used for various parts of the AST dump
34
35 struct TerminalColor {
36 raw_ostream::Colors Color;
37 bool Bold;
38 };
39
40 // Decl kind names (VarDecl, FunctionDecl, etc)
41 static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true };
42 // Attr names (CleanupAttr, GuardedByAttr, etc)
43 static const TerminalColor AttrColor = { raw_ostream::BLUE, true };
44 // Statement names (DeclStmt, ImplicitCastExpr, etc)
45 static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true };
46 // Comment names (FullComment, ParagraphComment, TextComment, etc)
47 static const TerminalColor CommentColor = { raw_ostream::YELLOW, true };
48
49 // Type names (int, float, etc, plus user defined types)
50 static const TerminalColor TypeColor = { raw_ostream::GREEN, false };
51
52 // Pointer address
53 static const TerminalColor AddressColor = { raw_ostream::YELLOW, false };
54 // Source locations
55 static const TerminalColor LocationColor = { raw_ostream::YELLOW, false };
56
57 // lvalue/xvalue
58 static const TerminalColor ValueKindColor = { raw_ostream::CYAN, false };
59 // bitfield/objcproperty/objcsubscript/vectorcomponent
60 static const TerminalColor ObjectKindColor = { raw_ostream::CYAN, false };
61
62 // Null statements
63 static const TerminalColor NullColor = { raw_ostream::BLUE, false };
64
65 // CastKind from CastExpr's
66 static const TerminalColor CastColor = { raw_ostream::RED, false };
67
68 // Value of the statement
69 static const TerminalColor ValueColor = { raw_ostream::CYAN, true };
70 // Decl names
71 static const TerminalColor DeclNameColor = { raw_ostream::CYAN, true };
72
Alexander Kornienkod538ed92012-12-20 02:09:13 +000073 class ASTDumper
Alexander Kornienkoacd356e2013-01-14 14:07:11 +000074 : public DeclVisitor<ASTDumper>, public StmtVisitor<ASTDumper>,
75 public ConstCommentVisitor<ASTDumper> {
Chris Lattner5f9e2722011-07-23 10:55:15 +000076 raw_ostream &OS;
Alexander Kornienkoacd356e2013-01-14 14:07:11 +000077 const CommandTraits *Traits;
78 const SourceManager *SM;
Chris Lattner6000dac2007-08-08 22:51:59 +000079 unsigned IndentLevel;
Manuel Klimekcb7b45e2012-11-07 00:33:12 +000080 bool IsFirstLine;
Mike Stump1eb44332009-09-09 15:08:12 +000081
Alexander Kornienko21c8b192012-12-11 15:28:09 +000082 /// Keep track of the last location we print out so that we can
83 /// print out deltas from then on out.
Chris Lattnere300c872007-08-30 06:17:34 +000084 const char *LastLocFilename;
85 unsigned LastLocLine;
Douglas Gregord249e1d1f2009-05-29 20:38:28 +000086
Alexander Kornienkoacd356e2013-01-14 14:07:11 +000087 /// The \c FullComment parent of the comment being dumped.
88 const FullComment *FC;
89
Richard Trieu7ba443a2013-01-26 01:31:20 +000090 bool ShowColors;
91
Manuel Klimekcb7b45e2012-11-07 00:33:12 +000092 class IndentScope {
Alexander Kornienko40b66a002012-12-13 13:59:55 +000093 ASTDumper &Dumper;
Manuel Klimekcb7b45e2012-11-07 00:33:12 +000094 public:
Alexander Kornienko40b66a002012-12-13 13:59:55 +000095 IndentScope(ASTDumper &Dumper) : Dumper(Dumper) {
Manuel Klimekcb7b45e2012-11-07 00:33:12 +000096 Dumper.indent();
97 }
98 ~IndentScope() {
99 Dumper.unindent();
100 }
101 };
102
Richard Trieu7ba443a2013-01-26 01:31:20 +0000103 class ColorScope {
104 ASTDumper &Dumper;
105 public:
106 ColorScope(ASTDumper &Dumper, TerminalColor Color)
107 : Dumper(Dumper) {
108 if (Dumper.ShowColors)
109 Dumper.OS.changeColor(Color.Color, Color.Bold);
110 }
111 ~ColorScope() {
112 if (Dumper.ShowColors)
113 Dumper.OS.resetColor();
114 }
115 };
116
Chris Lattner6000dac2007-08-08 22:51:59 +0000117 public:
Alexander Kornienkoacd356e2013-01-14 14:07:11 +0000118 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
119 const SourceManager *SM)
120 : OS(OS), Traits(Traits), SM(SM), IndentLevel(0), IsFirstLine(true),
Richard Trieu7ba443a2013-01-26 01:31:20 +0000121 LastLocFilename(""), LastLocLine(~0U), FC(0),
122 ShowColors(SM && SM->getDiagnostics().getShowColors()) { }
123
124 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
125 const SourceManager *SM, bool ShowColors)
126 : OS(OS), Traits(Traits), SM(SM), IndentLevel(0), IsFirstLine(true),
127 LastLocFilename(""), LastLocLine(~0U), ShowColors(ShowColors) { }
Mike Stump1eb44332009-09-09 15:08:12 +0000128
Alexander Kornienko40b66a002012-12-13 13:59:55 +0000129 ~ASTDumper() {
Manuel Klimekcb7b45e2012-11-07 00:33:12 +0000130 OS << "\n";
131 }
132
Alexander Kornienkod5bc3592012-12-11 15:20:44 +0000133 void dumpDecl(Decl *D);
134 void dumpStmt(Stmt *S);
Alexander Kornienkoacd356e2013-01-14 14:07:11 +0000135 void dumpFullComment(const FullComment *C);
Mike Stump1eb44332009-09-09 15:08:12 +0000136
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000137 // Utilities
138 void indent();
139 void unindent();
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000140 void dumpPointer(const void *Ptr);
141 void dumpSourceRange(SourceRange R);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000142 void dumpLocation(SourceLocation Loc);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000143 void dumpBareType(QualType T);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000144 void dumpType(QualType T);
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000145 void dumpBareDeclRef(const Decl *Node);
Alexander Kornienkoc9394532012-12-20 12:23:54 +0000146 void dumpDeclRef(const Decl *Node, const char *Label = 0);
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000147 void dumpName(const NamedDecl *D);
148 void dumpDeclContext(const DeclContext *DC);
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000149 void dumpAttr(const Attr *A);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000150
151 // C++ Utilities
152 void dumpAccessSpecifier(AccessSpecifier AS);
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000153 void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
154 void dumpTemplateParameters(const TemplateParameterList *TPL);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000155 void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
156 void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A);
157 void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
158 void dumpTemplateArgument(const TemplateArgument &A,
159 SourceRange R = SourceRange());
160
161 // Decls
162 void VisitLabelDecl(LabelDecl *D);
163 void VisitTypedefDecl(TypedefDecl *D);
164 void VisitEnumDecl(EnumDecl *D);
165 void VisitRecordDecl(RecordDecl *D);
166 void VisitEnumConstantDecl(EnumConstantDecl *D);
167 void VisitIndirectFieldDecl(IndirectFieldDecl *D);
168 void VisitFunctionDecl(FunctionDecl *D);
169 void VisitFieldDecl(FieldDecl *D);
170 void VisitVarDecl(VarDecl *D);
171 void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
172 void VisitImportDecl(ImportDecl *D);
173
174 // C++ Decls
175 void VisitNamespaceDecl(NamespaceDecl *D);
176 void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
177 void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
178 void VisitTypeAliasDecl(TypeAliasDecl *D);
179 void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
180 void VisitCXXRecordDecl(CXXRecordDecl *D);
181 void VisitStaticAssertDecl(StaticAssertDecl *D);
182 void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
183 void VisitClassTemplateDecl(ClassTemplateDecl *D);
184 void VisitClassTemplateSpecializationDecl(
185 ClassTemplateSpecializationDecl *D);
186 void VisitClassTemplatePartialSpecializationDecl(
187 ClassTemplatePartialSpecializationDecl *D);
188 void VisitClassScopeFunctionSpecializationDecl(
189 ClassScopeFunctionSpecializationDecl *D);
190 void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
191 void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
192 void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
193 void VisitUsingDecl(UsingDecl *D);
194 void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
195 void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
196 void VisitUsingShadowDecl(UsingShadowDecl *D);
197 void VisitLinkageSpecDecl(LinkageSpecDecl *D);
198 void VisitAccessSpecDecl(AccessSpecDecl *D);
199 void VisitFriendDecl(FriendDecl *D);
200
201 // ObjC Decls
202 void VisitObjCIvarDecl(ObjCIvarDecl *D);
203 void VisitObjCMethodDecl(ObjCMethodDecl *D);
204 void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
205 void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
206 void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
207 void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
208 void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
209 void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
210 void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
211 void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
212 void VisitBlockDecl(BlockDecl *D);
Mike Stump1eb44332009-09-09 15:08:12 +0000213
Chris Lattner17a1a722007-08-30 01:00:35 +0000214 // Stmts.
Chris Lattnerc5598cb2007-08-21 04:04:25 +0000215 void VisitStmt(Stmt *Node);
Ted Kremenek5399ce22007-12-12 06:59:42 +0000216 void VisitDeclStmt(DeclStmt *Node);
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000217 void VisitAttributedStmt(AttributedStmt *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000218 void VisitLabelStmt(LabelStmt *Node);
219 void VisitGotoStmt(GotoStmt *Node);
Mike Stump1eb44332009-09-09 15:08:12 +0000220
Chris Lattner17a1a722007-08-30 01:00:35 +0000221 // Exprs
222 void VisitExpr(Expr *Node);
Anders Carlsson27a5b9b2009-08-22 23:33:40 +0000223 void VisitCastExpr(CastExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000224 void VisitDeclRefExpr(DeclRefExpr *Node);
Chris Lattnerd9f69102008-08-10 01:53:14 +0000225 void VisitPredefinedExpr(PredefinedExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000226 void VisitCharacterLiteral(CharacterLiteral *Node);
227 void VisitIntegerLiteral(IntegerLiteral *Node);
228 void VisitFloatingLiteral(FloatingLiteral *Node);
229 void VisitStringLiteral(StringLiteral *Str);
230 void VisitUnaryOperator(UnaryOperator *Node);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +0000231 void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000232 void VisitMemberExpr(MemberExpr *Node);
Nate Begeman213541a2008-04-18 23:10:10 +0000233 void VisitExtVectorElementExpr(ExtVectorElementExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000234 void VisitBinaryOperator(BinaryOperator *Node);
235 void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
236 void VisitAddrLabelExpr(AddrLabelExpr *Node);
John McCall6b5a61b2011-02-07 10:33:21 +0000237 void VisitBlockExpr(BlockExpr *Node);
John McCall4b9c2d22011-11-06 09:01:30 +0000238 void VisitOpaqueValueExpr(OpaqueValueExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000239
240 // C++
Douglas Gregor49badde2008-10-27 19:41:14 +0000241 void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000242 void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
Douglas Gregorcd9b46e2008-11-04 14:56:14 +0000243 void VisitCXXThisExpr(CXXThisExpr *Node);
Douglas Gregor49badde2008-10-27 19:41:14 +0000244 void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
Anders Carlsson0eca1b62009-08-12 00:21:52 +0000245 void VisitCXXConstructExpr(CXXConstructExpr *Node);
246 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
John McCall4765fa02010-12-06 08:20:24 +0000247 void VisitExprWithCleanups(ExprWithCleanups *Node);
John McCall9d5f35e2009-12-11 21:50:11 +0000248 void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000249 void dumpCXXTemporary(CXXTemporary *Temporary);
Mike Stump1eb44332009-09-09 15:08:12 +0000250
Chris Lattner17a1a722007-08-30 01:00:35 +0000251 // ObjC
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +0000252 void VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node);
Chris Lattner17a1a722007-08-30 01:00:35 +0000253 void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000254 void VisitObjCMessageExpr(ObjCMessageExpr *Node);
255 void VisitObjCBoxedExpr(ObjCBoxedExpr *Node);
Fariborz Jahanianb62f6812007-10-16 20:40:23 +0000256 void VisitObjCSelectorExpr(ObjCSelectorExpr *Node);
Fariborz Jahanian390d50a2007-10-17 16:58:11 +0000257 void VisitObjCProtocolExpr(ObjCProtocolExpr *Node);
Daniel Dunbar7f8ea5c2008-08-30 05:35:15 +0000258 void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000259 void VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node);
Steve Naroff3c64d9e2008-03-12 13:19:12 +0000260 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
Ted Kremenekebcb57a2012-03-06 20:05:56 +0000261 void VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node);
Alexander Kornienkoacd356e2013-01-14 14:07:11 +0000262
263 // Comments.
264 const char *getCommandName(unsigned CommandID);
265 void dumpComment(const Comment *C);
266
267 // Inline comments.
268 void visitTextComment(const TextComment *C);
269 void visitInlineCommandComment(const InlineCommandComment *C);
270 void visitHTMLStartTagComment(const HTMLStartTagComment *C);
271 void visitHTMLEndTagComment(const HTMLEndTagComment *C);
272
273 // Block comments.
274 void visitBlockCommandComment(const BlockCommandComment *C);
275 void visitParamCommandComment(const ParamCommandComment *C);
276 void visitTParamCommandComment(const TParamCommandComment *C);
277 void visitVerbatimBlockComment(const VerbatimBlockComment *C);
278 void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
279 void visitVerbatimLineComment(const VerbatimLineComment *C);
Chris Lattner6000dac2007-08-08 22:51:59 +0000280 };
281}
282
283//===----------------------------------------------------------------------===//
Chris Lattnere300c872007-08-30 06:17:34 +0000284// Utilities
285//===----------------------------------------------------------------------===//
286
Alexander Kornienko40b66a002012-12-13 13:59:55 +0000287void ASTDumper::indent() {
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000288 if (IsFirstLine)
289 IsFirstLine = false;
290 else
291 OS << "\n";
292 OS.indent(IndentLevel * 2);
293 OS << "(";
294 IndentLevel++;
295}
296
Alexander Kornienko40b66a002012-12-13 13:59:55 +0000297void ASTDumper::unindent() {
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000298 OS << ")";
299 IndentLevel--;
300}
301
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000302void ASTDumper::dumpPointer(const void *Ptr) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000303 ColorScope Color(*this, AddressColor);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000304 OS << ' ' << Ptr;
305}
306
Alexander Kornienko40b66a002012-12-13 13:59:55 +0000307void ASTDumper::dumpLocation(SourceLocation Loc) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000308 ColorScope Color(*this, LocationColor);
Chris Lattnerdf7c17a2009-01-16 07:00:02 +0000309 SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
Mike Stump1eb44332009-09-09 15:08:12 +0000310
Chris Lattnere300c872007-08-30 06:17:34 +0000311 // The general format we print out is filename:line:col, but we drop pieces
312 // that haven't changed since the last loc printed.
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000313 PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
314
Douglas Gregorcb7b1e12010-11-12 07:15:47 +0000315 if (PLoc.isInvalid()) {
316 OS << "<invalid sloc>";
317 return;
318 }
319
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000320 if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000321 OS << PLoc.getFilename() << ':' << PLoc.getLine()
322 << ':' << PLoc.getColumn();
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000323 LastLocFilename = PLoc.getFilename();
324 LastLocLine = PLoc.getLine();
325 } else if (PLoc.getLine() != LastLocLine) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000326 OS << "line" << ':' << PLoc.getLine()
327 << ':' << PLoc.getColumn();
Chris Lattnerb9c3f962009-01-27 07:57:44 +0000328 LastLocLine = PLoc.getLine();
Chris Lattnere300c872007-08-30 06:17:34 +0000329 } else {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000330 OS << "col" << ':' << PLoc.getColumn();
Chris Lattnere300c872007-08-30 06:17:34 +0000331 }
332}
333
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000334void ASTDumper::dumpSourceRange(SourceRange R) {
Chris Lattnere300c872007-08-30 06:17:34 +0000335 // Can't translate locations if a SourceManager isn't available.
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000336 if (!SM)
337 return;
Mike Stump1eb44332009-09-09 15:08:12 +0000338
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000339 OS << " <";
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000340 dumpLocation(R.getBegin());
Chris Lattner311ff022007-10-16 22:36:42 +0000341 if (R.getBegin() != R.getEnd()) {
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000342 OS << ", ";
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000343 dumpLocation(R.getEnd());
Chris Lattnere300c872007-08-30 06:17:34 +0000344 }
Daniel Dunbar806c12e2009-12-03 09:13:13 +0000345 OS << ">";
Mike Stump1eb44332009-09-09 15:08:12 +0000346
Chris Lattnere300c872007-08-30 06:17:34 +0000347 // <t2.c:123:421[blah], t2.c:412:321>
348
349}
350
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000351void ASTDumper::dumpBareType(QualType T) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000352 ColorScope Color(*this, TypeColor);
353
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000354 SplitQualType T_split = T.split();
355 OS << "'" << QualType::getAsString(T_split) << "'";
356
357 if (!T.isNull()) {
358 // If the type is sugared, also dump a (shallow) desugared type.
359 SplitQualType D_split = T.getSplitDesugaredType();
360 if (T_split != D_split)
361 OS << ":'" << QualType::getAsString(D_split) << "'";
362 }
363}
364
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000365void ASTDumper::dumpType(QualType T) {
366 OS << ' ';
367 dumpBareType(T);
368}
369
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000370void ASTDumper::dumpBareDeclRef(const Decl *D) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000371 {
372 ColorScope Color(*this, DeclKindNameColor);
373 OS << D->getDeclKindName();
374 }
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000375 dumpPointer(D);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000376
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000377 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000378 ColorScope Color(*this, DeclNameColor);
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000379 OS << " '";
380 ND->getDeclName().printName(OS);
381 OS << "'";
382 }
383
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000384 if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000385 dumpType(VD->getType());
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000386}
387
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000388void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000389 if (!D)
390 return;
391
392 IndentScope Indent(*this);
393 if (Label)
394 OS << Label << ' ';
395 dumpBareDeclRef(D);
396}
397
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000398void ASTDumper::dumpName(const NamedDecl *ND) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000399 if (ND->getDeclName()) {
400 ColorScope Color(*this, DeclNameColor);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000401 OS << ' ' << ND->getNameAsString();
Richard Trieu7ba443a2013-01-26 01:31:20 +0000402 }
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000403}
404
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000405void ASTDumper::dumpDeclContext(const DeclContext *DC) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000406 if (!DC)
407 return;
408 for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end();
409 I != E; ++I)
410 dumpDecl(*I);
411}
412
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000413void ASTDumper::dumpAttr(const Attr *A) {
414 IndentScope Indent(*this);
Richard Trieu7ba443a2013-01-26 01:31:20 +0000415 {
416 ColorScope Color(*this, AttrColor);
417 switch (A->getKind()) {
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000418#define ATTR(X) case attr::X: OS << #X; break;
419#include "clang/Basic/AttrList.inc"
Richard Trieu7ba443a2013-01-26 01:31:20 +0000420 default: llvm_unreachable("unexpected attribute kind");
421 }
422 OS << "Attr";
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000423 }
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000424 dumpPointer(A);
425 dumpSourceRange(A->getRange());
426#include "clang/AST/AttrDump.inc"
427}
428
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000429//===----------------------------------------------------------------------===//
430// C++ Utilities
431//===----------------------------------------------------------------------===//
432
433void ASTDumper::dumpAccessSpecifier(AccessSpecifier AS) {
434 switch (AS) {
435 case AS_none:
436 break;
437 case AS_public:
438 OS << "public";
439 break;
440 case AS_protected:
441 OS << "protected";
442 break;
443 case AS_private:
444 OS << "private";
445 break;
446 }
447}
448
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000449void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000450 IndentScope Indent(*this);
451 OS << "CXXCtorInitializer";
452 if (Init->isAnyMemberInitializer()) {
453 OS << ' ';
454 dumpBareDeclRef(Init->getAnyMember());
455 } else {
456 dumpType(QualType(Init->getBaseClass(), 0));
457 }
458 dumpStmt(Init->getInit());
459}
460
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000461void ASTDumper::dumpTemplateParameters(const TemplateParameterList *TPL) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000462 if (!TPL)
463 return;
464
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000465 for (TemplateParameterList::const_iterator I = TPL->begin(), E = TPL->end();
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000466 I != E; ++I)
467 dumpDecl(*I);
468}
469
470void ASTDumper::dumpTemplateArgumentListInfo(
471 const TemplateArgumentListInfo &TALI) {
472 for (unsigned i = 0, e = TALI.size(); i < e; ++i)
473 dumpTemplateArgumentLoc(TALI[i]);
474}
475
476void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A) {
477 dumpTemplateArgument(A.getArgument(), A.getSourceRange());
478}
479
480void ASTDumper::dumpTemplateArgumentList(const TemplateArgumentList &TAL) {
481 for (unsigned i = 0, e = TAL.size(); i < e; ++i)
482 dumpTemplateArgument(TAL[i]);
483}
484
485void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R) {
486 IndentScope Indent(*this);
487 OS << "TemplateArgument";
488 if (R.isValid())
489 dumpSourceRange(R);
490
491 switch (A.getKind()) {
492 case TemplateArgument::Null:
493 OS << " null";
494 break;
495 case TemplateArgument::Type:
496 OS << " type";
497 dumpType(A.getAsType());
498 break;
499 case TemplateArgument::Declaration:
500 OS << " decl";
501 dumpDeclRef(A.getAsDecl());
502 break;
503 case TemplateArgument::NullPtr:
504 OS << " nullptr";
505 break;
506 case TemplateArgument::Integral:
Alexander Kornienkoad7bb362012-12-20 11:08:38 +0000507 OS << " integral " << A.getAsIntegral();
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000508 break;
509 case TemplateArgument::Template:
510 OS << " template ";
511 A.getAsTemplate().dump(OS);
512 break;
513 case TemplateArgument::TemplateExpansion:
514 OS << " template expansion";
515 A.getAsTemplateOrTemplatePattern().dump(OS);
516 break;
517 case TemplateArgument::Expression:
518 OS << " expr";
519 dumpStmt(A.getAsExpr());
520 break;
521 case TemplateArgument::Pack:
522 OS << " pack";
523 for (TemplateArgument::pack_iterator I = A.pack_begin(), E = A.pack_end();
524 I != E; ++I)
525 dumpTemplateArgument(*I);
526 break;
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000527 }
528}
529
Chris Lattnere300c872007-08-30 06:17:34 +0000530//===----------------------------------------------------------------------===//
Alexander Kornienko21c8b192012-12-11 15:28:09 +0000531// Decl dumping methods.
Chris Lattner6000dac2007-08-08 22:51:59 +0000532//===----------------------------------------------------------------------===//
533
Alexander Kornienko40b66a002012-12-13 13:59:55 +0000534void ASTDumper::dumpDecl(Decl *D) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000535 IndentScope Indent(*this);
Mike Stump1eb44332009-09-09 15:08:12 +0000536
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000537 if (!D) {
Richard Trieu7ba443a2013-01-26 01:31:20 +0000538 ColorScope Color(*this, NullColor);
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000539 OS << "<<<NULL>>>";
540 return;
Chris Lattner6000dac2007-08-08 22:51:59 +0000541 }
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000542
Richard Trieu7ba443a2013-01-26 01:31:20 +0000543 {
544 ColorScope Color(*this, DeclKindNameColor);
545 OS << D->getDeclKindName() << "Decl";
546 }
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000547 dumpPointer(D);
548 dumpSourceRange(D->getSourceRange());
549 DeclVisitor<ASTDumper>::Visit(D);
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +0000550 if (D->hasAttrs()) {
551 for (AttrVec::const_iterator I = D->getAttrs().begin(),
552 E = D->getAttrs().end(); I != E; ++I)
553 dumpAttr(*I);
554 }
Alexander Kornienkoacd356e2013-01-14 14:07:11 +0000555 dumpFullComment(D->getASTContext().getCommentForDecl(D, 0));
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000556 // Decls within functions are visited by the body
557 if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D))
558 dumpDeclContext(dyn_cast<DeclContext>(D));
559}
560
561void ASTDumper::VisitLabelDecl(LabelDecl *D) {
562 dumpName(D);
563}
564
565void ASTDumper::VisitTypedefDecl(TypedefDecl *D) {
566 dumpName(D);
567 dumpType(D->getUnderlyingType());
568 if (D->isModulePrivate())
569 OS << " __module_private__";
570}
571
572void ASTDumper::VisitEnumDecl(EnumDecl *D) {
573 if (D->isScoped()) {
574 if (D->isScopedUsingClassTag())
575 OS << " class";
576 else
577 OS << " struct";
578 }
579 dumpName(D);
580 if (D->isModulePrivate())
581 OS << " __module_private__";
582 if (D->isFixed())
583 dumpType(D->getIntegerType());
584}
585
586void ASTDumper::VisitRecordDecl(RecordDecl *D) {
587 OS << ' ' << D->getKindName();
588 dumpName(D);
589 if (D->isModulePrivate())
590 OS << " __module_private__";
591}
592
593void ASTDumper::VisitEnumConstantDecl(EnumConstantDecl *D) {
594 dumpName(D);
595 dumpType(D->getType());
596 if (Expr *Init = D->getInitExpr())
597 dumpStmt(Init);
598}
599
600void ASTDumper::VisitIndirectFieldDecl(IndirectFieldDecl *D) {
601 dumpName(D);
602 dumpType(D->getType());
603 for (IndirectFieldDecl::chain_iterator I = D->chain_begin(),
604 E = D->chain_end(); I != E; ++I)
605 dumpDeclRef(*I);
606}
607
608void ASTDumper::VisitFunctionDecl(FunctionDecl *D) {
609 dumpName(D);
610 dumpType(D->getType());
611
612 StorageClass SC = D->getStorageClassAsWritten();
613 if (SC != SC_None)
614 OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
615 if (D->isInlineSpecified())
616 OS << " inline";
617 if (D->isVirtualAsWritten())
618 OS << " virtual";
619 if (D->isModulePrivate())
620 OS << " __module_private__";
621
622 if (D->isPure())
623 OS << " pure";
624 else if (D->isDeletedAsWritten())
625 OS << " delete";
626
627 if (const FunctionTemplateSpecializationInfo *FTSI =
628 D->getTemplateSpecializationInfo())
629 dumpTemplateArgumentList(*FTSI->TemplateArguments);
630
Dmitri Gribenkocfa88f82013-01-12 19:30:44 +0000631 for (ArrayRef<NamedDecl *>::iterator
Alexander Kornienkod538ed92012-12-20 02:09:13 +0000632 I = D->getDeclsInPrototypeScope().begin(),
633 E = D->getDeclsInPrototypeScope().end(); I != E; ++I)
634 dumpDecl(*I);
635
636 for (FunctionDecl::param_iterator I = D->param_begin(), E = D->param_end();
637 I != E; ++I)
638 dumpDecl(*I);
639
640 if (CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(D))
641 for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
642 E = C->init_end(); I != E; ++I)
643 dumpCXXCtorInitializer(*I);
644
645 if (D->doesThisDeclarationHaveABody())
646 dumpStmt(D->getBody());
647}
648
649void ASTDumper::VisitFieldDecl(FieldDecl *D) {
650 dumpName(D);
651 dumpType(D->getType());
652 if (D->isMutable())
653 OS << " mutable";
654 if (D->isModulePrivate())
655 OS << " __module_private__";
656 if (D->isBitField())
657 dumpStmt(D->getBitWidth());
658 if (Expr *Init = D->getInClassInitializer())
659 dumpStmt(Init);
660}
661
662void ASTDumper::VisitVarDecl(VarDecl *D) {
663 dumpName(D);
664 dumpType(D->getType());
665 StorageClass SC = D->getStorageClassAsWritten();
666 if (SC != SC_None)
667 OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
668 if (D->isThreadSpecified())
669 OS << " __thread";
670 if (D->isModulePrivate())
671 OS << " __module_private__";
672 if (D->isNRVOVariable())
673 OS << " nrvo";
674 if (D->hasInit())
675 dumpStmt(D->getInit());
676}
677
678void ASTDumper::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
679 dumpStmt(D->getAsmString());
680}
681
682void ASTDumper::VisitImportDecl(ImportDecl *D) {
683 OS << ' ' << D->getImportedModule()->getFullModuleName();
684}
685
686//===----------------------------------------------------------------------===//
687// C++ Declarations
688//===----------------------------------------------------------------------===//
689
690void ASTDumper::VisitNamespaceDecl(NamespaceDecl *D) {
691 dumpName(D);
692 if (D->isInline())
693 OS << " inline";
694 if (!D->isOriginalNamespace())
695 dumpDeclRef(D->getOriginalNamespace(), "original");
696}
697
698void ASTDumper::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
699 OS << ' ';
700 dumpBareDeclRef(D->getNominatedNamespace());
701}
702
703void ASTDumper::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
704 dumpName(D);
705 dumpDeclRef(D->getAliasedNamespace());
706}
707
708void ASTDumper::VisitTypeAliasDecl(TypeAliasDecl *D) {
709 dumpName(D);
710 dumpType(D->getUnderlyingType());
711}
712
713void ASTDumper::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
714 dumpName(D);
715 dumpTemplateParameters(D->getTemplateParameters());
716 dumpDecl(D->getTemplatedDecl());
717}
718
719void ASTDumper::VisitCXXRecordDecl(CXXRecordDecl *D) {
720 VisitRecordDecl(D);
721 if (!D->isCompleteDefinition())
722 return;
723
724 for (CXXRecordDecl::base_class_iterator I = D->bases_begin(),
725 E = D->bases_end(); I != E; ++I) {
726 IndentScope Indent(*this);
727 if (I->isVirtual())
728 OS << "virtual ";
729 dumpAccessSpecifier(I->getAccessSpecifier());
730 dumpType(I->getType());
731 if (I->isPackExpansion())
732 OS << "...";
733 }
734}
735
736void ASTDumper::VisitStaticAssertDecl(StaticAssertDecl *D) {
737 dumpStmt(D->getAssertExpr());
738 dumpStmt(D->getMessage());
739}
740
741void ASTDumper::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
742 dumpName(D);
743 dumpTemplateParameters(D->getTemplateParameters());
744 dumpDecl(D->getTemplatedDecl());
745 for (FunctionTemplateDecl::spec_iterator I = D->spec_begin(),
746 E = D->spec_end(); I != E; ++I) {
747 switch (I->getTemplateSpecializationKind()) {
748 case TSK_Undeclared:
749 case TSK_ImplicitInstantiation:
750 case TSK_ExplicitInstantiationDeclaration:
751 case TSK_ExplicitInstantiationDefinition:
752 dumpDecl(*I);
753 break;
754 case TSK_ExplicitSpecialization:
755 dumpDeclRef(*I);
756 break;
757 }
758 }
759}
760
761void ASTDumper::VisitClassTemplateDecl(ClassTemplateDecl *D) {
762 dumpName(D);
763 dumpTemplateParameters(D->getTemplateParameters());
764 dumpDecl(D->getTemplatedDecl());
765 for (ClassTemplateDecl::spec_iterator I = D->spec_begin(), E = D->spec_end();
766 I != E; ++I) {
767 switch (I->getTemplateSpecializationKind()) {
768 case TSK_Undeclared:
769 case TSK_ImplicitInstantiation:
770 dumpDecl(*I);
771 break;
772 case TSK_ExplicitSpecialization:
773 case TSK_ExplicitInstantiationDeclaration:
774 case TSK_ExplicitInstantiationDefinition:
775 dumpDeclRef(*I);
776 break;
777 }
778 }
779}
780
781void ASTDumper::VisitClassTemplateSpecializationDecl(
782 ClassTemplateSpecializationDecl *D) {
783 VisitCXXRecordDecl(D);
784 dumpTemplateArgumentList(D->getTemplateArgs());
785}
786
787void ASTDumper::VisitClassTemplatePartialSpecializationDecl(
788 ClassTemplatePartialSpecializationDecl *D) {
789 VisitClassTemplateSpecializationDecl(D);
790 dumpTemplateParameters(D->getTemplateParameters());
791}
792
793void ASTDumper::VisitClassScopeFunctionSpecializationDecl(
794 ClassScopeFunctionSpecializationDecl *D) {
795 dumpDeclRef(D->getSpecialization());
796 if (D->hasExplicitTemplateArgs())
797 dumpTemplateArgumentListInfo(D->templateArgs());
798}
799
800void ASTDumper::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
801 if (D->wasDeclaredWithTypename())
802 OS << " typename";
803 else
804 OS << " class";
805 if (D->isParameterPack())
806 OS << " ...";
807 dumpName(D);
808 if (D->hasDefaultArgument())
809 dumpType(D->getDefaultArgument());
810}
811
812void ASTDumper::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
813 dumpType(D->getType());
814 if (D->isParameterPack())
815 OS << " ...";
816 dumpName(D);
817 if (D->hasDefaultArgument())
818 dumpStmt(D->getDefaultArgument());
819}
820
821void ASTDumper::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
822 if (D->isParameterPack())
823 OS << " ...";
824 dumpName(D);
825 dumpTemplateParameters(D->getTemplateParameters());
826 if (D->hasDefaultArgument())
827 dumpTemplateArgumentLoc(D->getDefaultArgument());
828}
829
830void ASTDumper::VisitUsingDecl(UsingDecl *D) {
831 OS << ' ';
832 D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
833 OS << D->getNameAsString();
834}
835
836void
837ASTDumper::VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) {
838 OS << ' ';
839 D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
840 OS << D->getNameAsString();
841}
842
843void ASTDumper::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
844 OS << ' ';
845 D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
846 OS << D->getNameAsString();
847 dumpType(D->getType());
848}
849
850void ASTDumper::VisitUsingShadowDecl(UsingShadowDecl *D) {
851 OS << ' ';
852 dumpBareDeclRef(D->getTargetDecl());
853}
854
855void ASTDumper::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
856 switch (D->getLanguage()) {
857 case LinkageSpecDecl::lang_c: OS << " C"; break;
858 case LinkageSpecDecl::lang_cxx: OS << " C++"; break;
859 }
860}
861
862void ASTDumper::VisitAccessSpecDecl(AccessSpecDecl *D) {
863 OS << ' ';
864 dumpAccessSpecifier(D->getAccess());
865}
866
867void ASTDumper::VisitFriendDecl(FriendDecl *D) {
868 if (TypeSourceInfo *T = D->getFriendType())
869 dumpType(T->getType());
870 else
871 dumpDecl(D->getFriendDecl());
872}
873
874//===----------------------------------------------------------------------===//
875// Obj-C Declarations
876//===----------------------------------------------------------------------===//
877
878void ASTDumper::VisitObjCIvarDecl(ObjCIvarDecl *D) {
879 dumpName(D);
880 dumpType(D->getType());
881 if (D->getSynthesize())
882 OS << " synthesize";
883
884 switch (D->getAccessControl()) {
885 case ObjCIvarDecl::None:
886 OS << " none";
887 break;
888 case ObjCIvarDecl::Private:
889 OS << " private";
890 break;
891 case ObjCIvarDecl::Protected:
892 OS << " protected";
893 break;
894 case ObjCIvarDecl::Public:
895 OS << " public";
896 break;
897 case ObjCIvarDecl::Package:
898 OS << " package";
899 break;
900 }
901}
902
903void ASTDumper::VisitObjCMethodDecl(ObjCMethodDecl *D) {
904 if (D->isInstanceMethod())
905 OS << " -";
906 else
907 OS << " +";
908 dumpName(D);
909 dumpType(D->getResultType());
910
911 if (D->isThisDeclarationADefinition())
912 dumpDeclContext(D);
913 else {
914 for (ObjCMethodDecl::param_iterator I = D->param_begin(),
915 E = D->param_end(); I != E; ++I) {
916 dumpDecl(*I);
917 }
918 }
919
920 if (D->isVariadic()) {
921 IndentScope Indent(*this);
922 OS << "...";
923 }
924
925 if (D->hasBody())
926 dumpStmt(D->getBody());
927}
928
929void ASTDumper::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
930 dumpName(D);
931 dumpDeclRef(D->getClassInterface());
932 dumpDeclRef(D->getImplementation());
933 for (ObjCCategoryDecl::protocol_iterator I = D->protocol_begin(),
934 E = D->protocol_end(); I != E; ++I)
935 dumpDeclRef(*I);
936}
937
938void ASTDumper::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
939 dumpName(D);
940 dumpDeclRef(D->getClassInterface());
941 dumpDeclRef(D->getCategoryDecl());
942}
943
944void ASTDumper::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
945 dumpName(D);
946 for (ObjCProtocolDecl::protocol_iterator I = D->protocol_begin(),
947 E = D->protocol_end(); I != E; ++I)
948 dumpDeclRef(*I);
949}
950
951void ASTDumper::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
952 dumpName(D);
953 dumpDeclRef(D->getSuperClass(), "super");
954 dumpDeclRef(D->getImplementation());
955 for (ObjCInterfaceDecl::protocol_iterator I = D->protocol_begin(),
956 E = D->protocol_end(); I != E; ++I)
957 dumpDeclRef(*I);
958}
959
960void ASTDumper::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
961 dumpName(D);
962 dumpDeclRef(D->getSuperClass(), "super");
963 dumpDeclRef(D->getClassInterface());
964 for (ObjCImplementationDecl::init_iterator I = D->init_begin(),
965 E = D->init_end(); I != E; ++I)
966 dumpCXXCtorInitializer(*I);
967}
968
969void ASTDumper::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {
970 dumpName(D);
971 dumpDeclRef(D->getClassInterface());
972}
973
974void ASTDumper::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
975 dumpName(D);
976 dumpType(D->getType());
977
978 if (D->getPropertyImplementation() == ObjCPropertyDecl::Required)
979 OS << " required";
980 else if (D->getPropertyImplementation() == ObjCPropertyDecl::Optional)
981 OS << " optional";
982
983 ObjCPropertyDecl::PropertyAttributeKind Attrs = D->getPropertyAttributes();
984 if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
985 if (Attrs & ObjCPropertyDecl::OBJC_PR_readonly)
986 OS << " readonly";
987 if (Attrs & ObjCPropertyDecl::OBJC_PR_assign)
988 OS << " assign";
989 if (Attrs & ObjCPropertyDecl::OBJC_PR_readwrite)
990 OS << " readwrite";
991 if (Attrs & ObjCPropertyDecl::OBJC_PR_retain)
992 OS << " retain";
993 if (Attrs & ObjCPropertyDecl::OBJC_PR_copy)
994 OS << " copy";
995 if (Attrs & ObjCPropertyDecl::OBJC_PR_nonatomic)
996 OS << " nonatomic";
997 if (Attrs & ObjCPropertyDecl::OBJC_PR_atomic)
998 OS << " atomic";
999 if (Attrs & ObjCPropertyDecl::OBJC_PR_weak)
1000 OS << " weak";
1001 if (Attrs & ObjCPropertyDecl::OBJC_PR_strong)
1002 OS << " strong";
1003 if (Attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained)
1004 OS << " unsafe_unretained";
1005 if (Attrs & ObjCPropertyDecl::OBJC_PR_getter)
1006 dumpDeclRef(D->getGetterMethodDecl(), "getter");
1007 if (Attrs & ObjCPropertyDecl::OBJC_PR_setter)
1008 dumpDeclRef(D->getSetterMethodDecl(), "setter");
1009 }
1010}
1011
1012void ASTDumper::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
1013 dumpName(D->getPropertyDecl());
1014 if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize)
1015 OS << " synthesize";
1016 else
1017 OS << " dynamic";
1018 dumpDeclRef(D->getPropertyDecl());
1019 dumpDeclRef(D->getPropertyIvarDecl());
1020}
1021
1022void ASTDumper::VisitBlockDecl(BlockDecl *D) {
1023 for (BlockDecl::param_iterator I = D->param_begin(), E = D->param_end();
1024 I != E; ++I)
1025 dumpDecl(*I);
1026
1027 if (D->isVariadic()) {
1028 IndentScope Indent(*this);
1029 OS << "...";
1030 }
1031
1032 if (D->capturesCXXThis()) {
1033 IndentScope Indent(*this);
1034 OS << "capture this";
1035 }
1036 for (BlockDecl::capture_iterator I = D->capture_begin(),
1037 E = D->capture_end(); I != E; ++I) {
1038 IndentScope Indent(*this);
1039 OS << "capture";
1040 if (I->isByRef())
1041 OS << " byref";
1042 if (I->isNested())
1043 OS << " nested";
1044 if (I->getVariable()) {
1045 OS << ' ';
1046 dumpBareDeclRef(I->getVariable());
1047 }
1048 if (I->hasCopyExpr())
1049 dumpStmt(I->getCopyExpr());
1050 }
1051
1052 dumpStmt(D->getBody());
Chris Lattner6000dac2007-08-08 22:51:59 +00001053}
1054
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001055//===----------------------------------------------------------------------===//
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001056// Stmt dumping methods.
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001057//===----------------------------------------------------------------------===//
1058
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001059void ASTDumper::dumpStmt(Stmt *S) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001060 IndentScope Indent(*this);
1061
1062 if (!S) {
Richard Trieu7ba443a2013-01-26 01:31:20 +00001063 ColorScope Color(*this, NullColor);
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001064 OS << "<<<NULL>>>";
1065 return;
1066 }
1067
1068 if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
1069 VisitDeclStmt(DS);
1070 return;
1071 }
1072
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001073 StmtVisitor<ASTDumper>::Visit(S);
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001074 for (Stmt::child_range CI = S->children(); CI; ++CI)
1075 dumpStmt(*CI);
1076}
1077
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001078void ASTDumper::VisitStmt(Stmt *Node) {
Richard Trieu7ba443a2013-01-26 01:31:20 +00001079 {
1080 ColorScope Color(*this, StmtColor);
1081 OS << Node->getStmtClassName();
1082 }
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001083 dumpPointer(Node);
1084 dumpSourceRange(Node->getSourceRange());
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001085}
1086
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001087void ASTDumper::VisitDeclStmt(DeclStmt *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001088 VisitStmt(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001089 for (DeclStmt::decl_iterator I = Node->decl_begin(), E = Node->decl_end();
1090 I != E; ++I)
1091 dumpDecl(*I);
Ted Kremenek5399ce22007-12-12 06:59:42 +00001092}
1093
Alexander Kornienkoc3cd2b02013-01-07 17:53:08 +00001094void ASTDumper::VisitAttributedStmt(AttributedStmt *Node) {
1095 VisitStmt(Node);
1096 for (ArrayRef<const Attr*>::iterator I = Node->getAttrs().begin(),
1097 E = Node->getAttrs().end(); I != E; ++I)
1098 dumpAttr(*I);
1099}
1100
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001101void ASTDumper::VisitLabelStmt(LabelStmt *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001102 VisitStmt(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001103 OS << " '" << Node->getName() << "'";
Chris Lattner6000dac2007-08-08 22:51:59 +00001104}
1105
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001106void ASTDumper::VisitGotoStmt(GotoStmt *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001107 VisitStmt(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001108 OS << " '" << Node->getLabel()->getName() << "'";
1109 dumpPointer(Node->getLabel());
Chris Lattner6000dac2007-08-08 22:51:59 +00001110}
1111
Chris Lattner6000dac2007-08-08 22:51:59 +00001112//===----------------------------------------------------------------------===//
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001113// Expr dumping methods.
Chris Lattner6000dac2007-08-08 22:51:59 +00001114//===----------------------------------------------------------------------===//
1115
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001116void ASTDumper::VisitExpr(Expr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001117 VisitStmt(Node);
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001118 dumpType(Node->getType());
1119
Richard Trieu7ba443a2013-01-26 01:31:20 +00001120 {
1121 ColorScope Color(*this, ValueKindColor);
1122 switch (Node->getValueKind()) {
1123 case VK_RValue:
1124 break;
1125 case VK_LValue:
1126 OS << " lvalue";
1127 break;
1128 case VK_XValue:
1129 OS << " xvalue";
1130 break;
1131 }
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001132 }
1133
Richard Trieu7ba443a2013-01-26 01:31:20 +00001134 {
1135 ColorScope Color(*this, ObjectKindColor);
1136 switch (Node->getObjectKind()) {
1137 case OK_Ordinary:
1138 break;
1139 case OK_BitField:
1140 OS << " bitfield";
1141 break;
1142 case OK_ObjCProperty:
1143 OS << " objcproperty";
1144 break;
1145 case OK_ObjCSubscript:
1146 OS << " objcsubscript";
1147 break;
1148 case OK_VectorComponent:
1149 OS << " vectorcomponent";
1150 break;
1151 }
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001152 }
Chris Lattner6000dac2007-08-08 22:51:59 +00001153}
1154
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001155static void dumpBasePath(raw_ostream &OS, CastExpr *Node) {
John McCallf871d0c2010-08-07 06:22:56 +00001156 if (Node->path_empty())
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001157 return;
1158
1159 OS << " (";
1160 bool First = true;
John McCallf871d0c2010-08-07 06:22:56 +00001161 for (CastExpr::path_iterator
1162 I = Node->path_begin(), E = Node->path_end(); I != E; ++I) {
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001163 const CXXBaseSpecifier *Base = *I;
1164 if (!First)
1165 OS << " -> ";
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001166
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001167 const CXXRecordDecl *RD =
1168 cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001169
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001170 if (Base->isVirtual())
1171 OS << "virtual ";
1172 OS << RD->getName();
1173 First = false;
1174 }
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001175
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001176 OS << ')';
1177}
1178
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001179void ASTDumper::VisitCastExpr(CastExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001180 VisitExpr(Node);
Richard Trieu7ba443a2013-01-26 01:31:20 +00001181 OS << " <";
1182 {
1183 ColorScope Color(*this, CastColor);
1184 OS << Node->getCastKindName();
1185 }
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001186 dumpBasePath(OS, Node);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001187 OS << ">";
Anders Carlsson27a5b9b2009-08-22 23:33:40 +00001188}
1189
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001190void ASTDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001191 VisitExpr(Node);
Ted Kremenekeb641f92007-09-10 17:32:55 +00001192
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001193 OS << " ";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001194 dumpBareDeclRef(Node->getDecl());
Chandler Carruth3aa81402011-05-01 23:48:14 +00001195 if (Node->getDecl() != Node->getFoundDecl()) {
1196 OS << " (";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001197 dumpBareDeclRef(Node->getFoundDecl());
Chandler Carruth3aa81402011-05-01 23:48:14 +00001198 OS << ")";
1199 }
John McCall6b5a61b2011-02-07 10:33:21 +00001200}
1201
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001202void ASTDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001203 VisitExpr(Node);
John McCall9d5f35e2009-12-11 21:50:11 +00001204 OS << " (";
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001205 if (!Node->requiresADL())
1206 OS << "no ";
Benjamin Kramer900fc632010-04-17 09:33:03 +00001207 OS << "ADL) = '" << Node->getName() << '\'';
John McCall9d5f35e2009-12-11 21:50:11 +00001208
1209 UnresolvedLookupExpr::decls_iterator
1210 I = Node->decls_begin(), E = Node->decls_end();
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001211 if (I == E)
1212 OS << " empty";
John McCall9d5f35e2009-12-11 21:50:11 +00001213 for (; I != E; ++I)
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001214 dumpPointer(*I);
John McCall9d5f35e2009-12-11 21:50:11 +00001215}
1216
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001217void ASTDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001218 VisitExpr(Node);
Steve Naroff3c64d9e2008-03-12 13:19:12 +00001219
Richard Trieu7ba443a2013-01-26 01:31:20 +00001220 {
1221 ColorScope Color(*this, DeclKindNameColor);
1222 OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
1223 }
1224 OS << "='" << *Node->getDecl() << "'";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001225 dumpPointer(Node->getDecl());
Steve Naroff218543b2008-05-23 22:01:24 +00001226 if (Node->isFreeIvar())
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001227 OS << " isFreeIvar";
Steve Naroff3c64d9e2008-03-12 13:19:12 +00001228}
1229
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001230void ASTDumper::VisitPredefinedExpr(PredefinedExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001231 VisitExpr(Node);
Chris Lattner6000dac2007-08-08 22:51:59 +00001232 switch (Node->getIdentType()) {
David Blaikieb219cfc2011-09-23 05:06:16 +00001233 default: llvm_unreachable("unknown case");
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001234 case PredefinedExpr::Func: OS << " __func__"; break;
1235 case PredefinedExpr::Function: OS << " __FUNCTION__"; break;
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001236 case PredefinedExpr::LFunction: OS << " L__FUNCTION__"; break;
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001237 case PredefinedExpr::PrettyFunction: OS << " __PRETTY_FUNCTION__";break;
Chris Lattner6000dac2007-08-08 22:51:59 +00001238 }
1239}
1240
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001241void ASTDumper::VisitCharacterLiteral(CharacterLiteral *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001242 VisitExpr(Node);
Richard Trieu7ba443a2013-01-26 01:31:20 +00001243 ColorScope Color(*this, ValueColor);
Richard Trieu49cf8842011-11-03 23:56:23 +00001244 OS << " " << Node->getValue();
Chris Lattner6000dac2007-08-08 22:51:59 +00001245}
1246
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001247void ASTDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001248 VisitExpr(Node);
Chris Lattner6000dac2007-08-08 22:51:59 +00001249
1250 bool isSigned = Node->getType()->isSignedIntegerType();
Richard Trieu7ba443a2013-01-26 01:31:20 +00001251 ColorScope Color(*this, ValueColor);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001252 OS << " " << Node->getValue().toString(10, isSigned);
Chris Lattner6000dac2007-08-08 22:51:59 +00001253}
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001254
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001255void ASTDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001256 VisitExpr(Node);
Richard Trieu7ba443a2013-01-26 01:31:20 +00001257 ColorScope Color(*this, ValueColor);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001258 OS << " " << Node->getValueAsApproximateDouble();
Chris Lattner6000dac2007-08-08 22:51:59 +00001259}
Chris Lattner5d661452007-08-26 03:42:43 +00001260
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001261void ASTDumper::VisitStringLiteral(StringLiteral *Str) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001262 VisitExpr(Str);
Richard Trieu7ba443a2013-01-26 01:31:20 +00001263 ColorScope Color(*this, ValueColor);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001264 OS << " ";
Richard Trieu8ab09da2012-06-13 20:25:24 +00001265 Str->outputString(OS);
Chris Lattner6000dac2007-08-08 22:51:59 +00001266}
Chris Lattner17a1a722007-08-30 01:00:35 +00001267
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001268void ASTDumper::VisitUnaryOperator(UnaryOperator *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001269 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001270 OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
1271 << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattner6000dac2007-08-08 22:51:59 +00001272}
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001273
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001274void ASTDumper::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001275 VisitExpr(Node);
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001276 switch(Node->getKind()) {
1277 case UETT_SizeOf:
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001278 OS << " sizeof";
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001279 break;
1280 case UETT_AlignOf:
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001281 OS << " alignof";
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001282 break;
1283 case UETT_VecStep:
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001284 OS << " vec_step";
Peter Collingbournef4e3cfb2011-03-11 19:24:49 +00001285 break;
1286 }
Sebastian Redl05189992008-11-11 17:56:53 +00001287 if (Node->isArgumentType())
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001288 dumpType(Node->getArgumentType());
Chris Lattner6000dac2007-08-08 22:51:59 +00001289}
Chris Lattner13cb21f2007-08-09 17:35:30 +00001290
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001291void ASTDumper::VisitMemberExpr(MemberExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001292 VisitExpr(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001293 OS << " " << (Node->isArrow() ? "->" : ".") << *Node->getMemberDecl();
1294 dumpPointer(Node->getMemberDecl());
Chris Lattner6000dac2007-08-08 22:51:59 +00001295}
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001296
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001297void ASTDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001298 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001299 OS << " " << Node->getAccessor().getNameStart();
Chris Lattner6000dac2007-08-08 22:51:59 +00001300}
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001301
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001302void ASTDumper::VisitBinaryOperator(BinaryOperator *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001303 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001304 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Chris Lattnereb14fe82007-08-25 02:00:02 +00001305}
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001306
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001307void ASTDumper::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001308 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001309 OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
1310 << "' ComputeLHSTy=";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001311 dumpBareType(Node->getComputationLHSType());
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001312 OS << " ComputeResultTy=";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001313 dumpBareType(Node->getComputationResultType());
Chris Lattner6000dac2007-08-08 22:51:59 +00001314}
Chris Lattner6000dac2007-08-08 22:51:59 +00001315
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001316void ASTDumper::VisitBlockExpr(BlockExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001317 VisitExpr(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001318 dumpDecl(Node->getBlockDecl());
John McCall6b5a61b2011-02-07 10:33:21 +00001319}
1320
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001321void ASTDumper::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001322 VisitExpr(Node);
John McCall4b9c2d22011-11-06 09:01:30 +00001323
Manuel Klimekcb7b45e2012-11-07 00:33:12 +00001324 if (Expr *Source = Node->getSourceExpr())
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001325 dumpStmt(Source);
John McCall4b9c2d22011-11-06 09:01:30 +00001326}
1327
Chris Lattner6000dac2007-08-08 22:51:59 +00001328// GNU extensions.
1329
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001330void ASTDumper::VisitAddrLabelExpr(AddrLabelExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001331 VisitExpr(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001332 OS << " " << Node->getLabel()->getName();
1333 dumpPointer(Node->getLabel());
Chris Lattner6000dac2007-08-08 22:51:59 +00001334}
1335
Chris Lattnerf9e05812007-08-09 18:03:18 +00001336//===----------------------------------------------------------------------===//
1337// C++ Expressions
1338//===----------------------------------------------------------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +00001339
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001340void ASTDumper::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001341 VisitExpr(Node);
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001342 OS << " " << Node->getCastName()
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001343 << "<" << Node->getTypeAsWritten().getAsString() << ">"
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001344 << " <" << Node->getCastKindName();
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001345 dumpBasePath(OS, Node);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001346 OS << ">";
Chris Lattner6000dac2007-08-08 22:51:59 +00001347}
1348
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001349void ASTDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001350 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001351 OS << " " << (Node->getValue() ? "true" : "false");
Chris Lattner6000dac2007-08-08 22:51:59 +00001352}
1353
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001354void ASTDumper::VisitCXXThisExpr(CXXThisExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001355 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001356 OS << " this";
Douglas Gregorcd9b46e2008-11-04 14:56:14 +00001357}
1358
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001359void ASTDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001360 VisitExpr(Node);
Eli Friedmancc2fca22011-09-02 17:38:59 +00001361 OS << " functional cast to " << Node->getTypeAsWritten().getAsString()
1362 << " <" << Node->getCastKindName() << ">";
Douglas Gregor49badde2008-10-27 19:41:14 +00001363}
1364
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001365void ASTDumper::VisitCXXConstructExpr(CXXConstructExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001366 VisitExpr(Node);
John McCalld4bbdfe2010-02-02 19:03:45 +00001367 CXXConstructorDecl *Ctor = Node->getConstructor();
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001368 dumpType(Ctor->getType());
Anders Carlsson0eca1b62009-08-12 00:21:52 +00001369 if (Node->isElidable())
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001370 OS << " elidable";
John McCallf8cf0b02010-08-07 06:38:55 +00001371 if (Node->requiresZeroInitialization())
1372 OS << " zeroing";
Anders Carlsson0eca1b62009-08-12 00:21:52 +00001373}
1374
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001375void ASTDumper::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001376 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001377 OS << " ";
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001378 dumpCXXTemporary(Node->getTemporary());
Anders Carlsson0eca1b62009-08-12 00:21:52 +00001379}
1380
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001381void ASTDumper::VisitExprWithCleanups(ExprWithCleanups *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001382 VisitExpr(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001383 for (unsigned i = 0, e = Node->getNumObjects(); i != e; ++i)
1384 dumpDeclRef(Node->getObject(i), "cleanup");
Anders Carlsson0eca1b62009-08-12 00:21:52 +00001385}
1386
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001387void ASTDumper::dumpCXXTemporary(CXXTemporary *Temporary) {
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001388 OS << "(CXXTemporary";
1389 dumpPointer(Temporary);
1390 OS << ")";
Anders Carlsson0eca1b62009-08-12 00:21:52 +00001391}
1392
Anders Carlsson55085182007-08-21 17:43:55 +00001393//===----------------------------------------------------------------------===//
1394// Obj-C Expressions
1395//===----------------------------------------------------------------------===//
1396
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001397void ASTDumper::VisitObjCMessageExpr(ObjCMessageExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001398 VisitExpr(Node);
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001399 OS << " selector=" << Node->getSelector().getAsString();
Douglas Gregor04badcf2010-04-21 00:45:42 +00001400 switch (Node->getReceiverKind()) {
1401 case ObjCMessageExpr::Instance:
1402 break;
1403
1404 case ObjCMessageExpr::Class:
1405 OS << " class=";
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001406 dumpBareType(Node->getClassReceiver());
Douglas Gregor04badcf2010-04-21 00:45:42 +00001407 break;
1408
1409 case ObjCMessageExpr::SuperInstance:
1410 OS << " super (instance)";
1411 break;
1412
1413 case ObjCMessageExpr::SuperClass:
1414 OS << " super (class)";
1415 break;
1416 }
Ted Kremenekb3d914b2008-02-29 22:04:05 +00001417}
1418
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001419void ASTDumper::VisitObjCBoxedExpr(ObjCBoxedExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001420 VisitExpr(Node);
Argyrios Kyrtzidis36faadd2012-05-10 20:02:31 +00001421 OS << " selector=" << Node->getBoxingMethod()->getSelector().getAsString();
1422}
1423
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001424void ASTDumper::VisitObjCAtCatchStmt(ObjCAtCatchStmt *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001425 VisitStmt(Node);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001426 if (VarDecl *CatchParam = Node->getCatchParamDecl())
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001427 dumpDecl(CatchParam);
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001428 else
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001429 OS << " catch all";
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001430}
1431
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001432void ASTDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001433 VisitExpr(Node);
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001434 dumpType(Node->getEncodedType());
Anders Carlssonf9bcf012007-08-22 15:14:15 +00001435}
1436
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001437void ASTDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001438 VisitExpr(Node);
Mike Stump1eb44332009-09-09 15:08:12 +00001439
Daniel Dunbar806c12e2009-12-03 09:13:13 +00001440 OS << " " << Node->getSelector().getAsString();
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00001441}
1442
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001443void ASTDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001444 VisitExpr(Node);
Mike Stump1eb44332009-09-09 15:08:12 +00001445
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001446 OS << ' ' << *Node->getProtocol();
Fariborz Jahanian390d50a2007-10-17 16:58:11 +00001447}
Daniel Dunbar7f8ea5c2008-08-30 05:35:15 +00001448
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001449void ASTDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001450 VisitExpr(Node);
John McCall12f78a62010-12-02 01:19:52 +00001451 if (Node->isImplicitProperty()) {
Fariborz Jahanian99130e52010-12-22 19:46:35 +00001452 OS << " Kind=MethodRef Getter=\"";
1453 if (Node->getImplicitPropertyGetter())
1454 OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
1455 else
1456 OS << "(null)";
1457
1458 OS << "\" Setter=\"";
John McCall12f78a62010-12-02 01:19:52 +00001459 if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter())
1460 OS << Setter->getSelector().getAsString();
1461 else
1462 OS << "(null)";
1463 OS << "\"";
1464 } else {
Benjamin Kramerb8989f22011-10-14 18:45:37 +00001465 OS << " Kind=PropertyRef Property=\"" << *Node->getExplicitProperty() <<'"';
John McCall12f78a62010-12-02 01:19:52 +00001466 }
Fariborz Jahanian5daf5702008-11-22 18:39:36 +00001467
Fariborz Jahanian8ac2d442010-10-14 16:04:05 +00001468 if (Node->isSuperReceiver())
1469 OS << " super";
Argyrios Kyrtzidisb085d892012-03-30 00:19:18 +00001470
1471 OS << " Messaging=";
1472 if (Node->isMessagingGetter() && Node->isMessagingSetter())
1473 OS << "Getter&Setter";
1474 else if (Node->isMessagingGetter())
1475 OS << "Getter";
1476 else if (Node->isMessagingSetter())
1477 OS << "Setter";
Douglas Gregorcd9b46e2008-11-04 14:56:14 +00001478}
1479
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001480void ASTDumper::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001481 VisitExpr(Node);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001482 if (Node->isArraySubscriptRefExpr())
1483 OS << " Kind=ArraySubscript GetterForArray=\"";
1484 else
1485 OS << " Kind=DictionarySubscript GetterForDictionary=\"";
1486 if (Node->getAtIndexMethodDecl())
1487 OS << Node->getAtIndexMethodDecl()->getSelector().getAsString();
1488 else
1489 OS << "(null)";
Alexander Kornienko21c8b192012-12-11 15:28:09 +00001490
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001491 if (Node->isArraySubscriptRefExpr())
1492 OS << "\" SetterForArray=\"";
1493 else
1494 OS << "\" SetterForDictionary=\"";
1495 if (Node->setAtIndexMethodDecl())
1496 OS << Node->setAtIndexMethodDecl()->getSelector().getAsString();
1497 else
1498 OS << "(null)";
1499}
1500
Alexander Kornienko40b66a002012-12-13 13:59:55 +00001501void ASTDumper::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Node) {
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001502 VisitExpr(Node);
Ted Kremenekebcb57a2012-03-06 20:05:56 +00001503 OS << " " << (Node->getValue() ? "__objc_yes" : "__objc_no");
1504}
1505
Chris Lattner6000dac2007-08-08 22:51:59 +00001506//===----------------------------------------------------------------------===//
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001507// Comments
1508//===----------------------------------------------------------------------===//
1509
1510const char *ASTDumper::getCommandName(unsigned CommandID) {
1511 if (Traits)
1512 return Traits->getCommandInfo(CommandID)->Name;
1513 const CommandInfo *Info = CommandTraits::getBuiltinCommandInfo(CommandID);
1514 if (Info)
1515 return Info->Name;
1516 return "<not a builtin command>";
1517}
1518
1519void ASTDumper::dumpFullComment(const FullComment *C) {
1520 if (!C)
1521 return;
1522
1523 FC = C;
1524 dumpComment(C);
1525 FC = 0;
1526}
1527
1528void ASTDumper::dumpComment(const Comment *C) {
1529 IndentScope Indent(*this);
1530
1531 if (!C) {
Richard Trieu7ba443a2013-01-26 01:31:20 +00001532 ColorScope Color(*this, NullColor);
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001533 OS << "<<<NULL>>>";
1534 return;
1535 }
1536
Richard Trieu7ba443a2013-01-26 01:31:20 +00001537 {
1538 ColorScope Color(*this, CommentColor);
1539 OS << C->getCommentKindName();
1540 }
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001541 dumpPointer(C);
1542 dumpSourceRange(C->getSourceRange());
1543 ConstCommentVisitor<ASTDumper>::visit(C);
1544 for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
1545 I != E; ++I)
1546 dumpComment(*I);
1547}
1548
1549void ASTDumper::visitTextComment(const TextComment *C) {
1550 OS << " Text=\"" << C->getText() << "\"";
1551}
1552
1553void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C) {
1554 OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
1555 switch (C->getRenderKind()) {
1556 case InlineCommandComment::RenderNormal:
1557 OS << " RenderNormal";
1558 break;
1559 case InlineCommandComment::RenderBold:
1560 OS << " RenderBold";
1561 break;
1562 case InlineCommandComment::RenderMonospaced:
1563 OS << " RenderMonospaced";
1564 break;
1565 case InlineCommandComment::RenderEmphasized:
1566 OS << " RenderEmphasized";
1567 break;
1568 }
1569
1570 for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
1571 OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
1572}
1573
1574void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
1575 OS << " Name=\"" << C->getTagName() << "\"";
1576 if (C->getNumAttrs() != 0) {
1577 OS << " Attrs: ";
1578 for (unsigned i = 0, e = C->getNumAttrs(); i != e; ++i) {
1579 const HTMLStartTagComment::Attribute &Attr = C->getAttr(i);
1580 OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
1581 }
1582 }
1583 if (C->isSelfClosing())
1584 OS << " SelfClosing";
1585}
1586
1587void ASTDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C) {
1588 OS << " Name=\"" << C->getTagName() << "\"";
1589}
1590
1591void ASTDumper::visitBlockCommandComment(const BlockCommandComment *C) {
1592 OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
1593 for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
1594 OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
1595}
1596
1597void ASTDumper::visitParamCommandComment(const ParamCommandComment *C) {
1598 OS << " " << ParamCommandComment::getDirectionAsString(C->getDirection());
1599
1600 if (C->isDirectionExplicit())
1601 OS << " explicitly";
1602 else
1603 OS << " implicitly";
1604
1605 if (C->hasParamName()) {
1606 if (C->isParamIndexValid())
1607 OS << " Param=\"" << C->getParamName(FC) << "\"";
1608 else
1609 OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
1610 }
1611
1612 if (C->isParamIndexValid())
1613 OS << " ParamIndex=" << C->getParamIndex();
1614}
1615
1616void ASTDumper::visitTParamCommandComment(const TParamCommandComment *C) {
1617 if (C->hasParamName()) {
1618 if (C->isPositionValid())
1619 OS << " Param=\"" << C->getParamName(FC) << "\"";
1620 else
1621 OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
1622 }
1623
1624 if (C->isPositionValid()) {
1625 OS << " Position=<";
1626 for (unsigned i = 0, e = C->getDepth(); i != e; ++i) {
1627 OS << C->getIndex(i);
1628 if (i != e - 1)
1629 OS << ", ";
1630 }
1631 OS << ">";
1632 }
1633}
1634
1635void ASTDumper::visitVerbatimBlockComment(const VerbatimBlockComment *C) {
1636 OS << " Name=\"" << getCommandName(C->getCommandID()) << "\""
1637 " CloseName=\"" << C->getCloseName() << "\"";
1638}
1639
1640void ASTDumper::visitVerbatimBlockLineComment(
1641 const VerbatimBlockLineComment *C) {
1642 OS << " Text=\"" << C->getText() << "\"";
1643}
1644
1645void ASTDumper::visitVerbatimLineComment(const VerbatimLineComment *C) {
1646 OS << " Text=\"" << C->getText() << "\"";
1647}
1648
1649//===----------------------------------------------------------------------===//
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001650// Decl method implementations
1651//===----------------------------------------------------------------------===//
1652
1653void Decl::dump() const {
1654 dump(llvm::errs());
1655}
1656
1657void Decl::dump(raw_ostream &OS) const {
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001658 ASTDumper P(OS, &getASTContext().getCommentCommandTraits(),
1659 &getASTContext().getSourceManager());
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001660 P.dumpDecl(const_cast<Decl*>(this));
1661}
1662
Richard Trieu7ba443a2013-01-26 01:31:20 +00001663void Decl::dumpColor() const {
1664 ASTDumper P(llvm::errs(), &getASTContext().getCommentCommandTraits(),
1665 &getASTContext().getSourceManager(), /*ShowColors*/true);
1666 P.dumpDecl(const_cast<Decl*>(this));
1667}
Alexander Kornienkod538ed92012-12-20 02:09:13 +00001668//===----------------------------------------------------------------------===//
Chris Lattner6000dac2007-08-08 22:51:59 +00001669// Stmt method implementations
1670//===----------------------------------------------------------------------===//
1671
Chris Lattnere300c872007-08-30 06:17:34 +00001672void Stmt::dump(SourceManager &SM) const {
Argyrios Kyrtzidis96680332010-08-09 10:54:31 +00001673 dump(llvm::errs(), SM);
1674}
1675
Chris Lattner5f9e2722011-07-23 10:55:15 +00001676void Stmt::dump(raw_ostream &OS, SourceManager &SM) const {
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001677 ASTDumper P(OS, 0, &SM);
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001678 P.dumpStmt(const_cast<Stmt*>(this));
Chris Lattner0c727a32007-08-30 00:40:08 +00001679}
1680
Chris Lattner6000dac2007-08-08 22:51:59 +00001681void Stmt::dump() const {
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001682 ASTDumper P(llvm::errs(), 0, 0);
Alexander Kornienkod5bc3592012-12-11 15:20:44 +00001683 P.dumpStmt(const_cast<Stmt*>(this));
Chris Lattner6000dac2007-08-08 22:51:59 +00001684}
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001685
Richard Trieu7ba443a2013-01-26 01:31:20 +00001686void Stmt::dumpColor() const {
1687 ASTDumper P(llvm::errs(), 0, 0, /*ShowColors*/true);
1688 P.dumpStmt(const_cast<Stmt*>(this));
1689}
1690
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001691//===----------------------------------------------------------------------===//
1692// Comment method implementations
1693//===----------------------------------------------------------------------===//
1694
1695void Comment::dump() const {
1696 dump(llvm::errs(), 0, 0);
1697}
1698
1699void Comment::dump(const ASTContext &Context) const {
1700 dump(llvm::errs(), &Context.getCommentCommandTraits(),
1701 &Context.getSourceManager());
1702}
1703
Alexander Kornienko51ccafd2013-01-15 12:20:21 +00001704void Comment::dump(raw_ostream &OS, const CommandTraits *Traits,
Alexander Kornienkoacd356e2013-01-14 14:07:11 +00001705 const SourceManager *SM) const {
1706 const FullComment *FC = dyn_cast<FullComment>(this);
1707 ASTDumper D(OS, Traits, SM);
1708 D.dumpFullComment(FC);
1709}
Richard Trieu7ba443a2013-01-26 01:31:20 +00001710
1711void Comment::dumpColor() const {
1712 const FullComment *FC = dyn_cast<FullComment>(this);
1713 ASTDumper D(llvm::errs(), 0, 0, /*ShowColors*/true);
1714 D.dumpFullComment(FC);
1715}