blob: 00d1f0123b45b8cd1fd4dd6f53bcbd2f9453a4ca [file] [log] [blame]
Alexander Kornienko18ec81b2012-12-13 13:59:55 +00001//===--- ASTDumper.cpp - Dumping implementation for ASTs ------------------===//
Chris Lattnercbe4f772007-08-08 22:51:59 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Lattnercbe4f772007-08-08 22:51:59 +00006//
7//===----------------------------------------------------------------------===//
8//
Alexander Kornienko18ec81b2012-12-13 13:59:55 +00009// This file implements the AST dump methods, which dump out the
Chris Lattnercbe4f772007-08-08 22:51:59 +000010// AST in a form that exposes type details and other fields.
11//
12//===----------------------------------------------------------------------===//
13
Chandler Carruth3a022472012-12-04 09:13:33 +000014#include "clang/AST/ASTContext.h"
Stephen Kelly0da68ba2018-12-05 20:53:14 +000015#include "clang/AST/ASTDumperUtils.h"
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000016#include "clang/AST/Attr.h"
Stephen Kellydb8fac12019-01-11 19:16:01 +000017#include "clang/AST/AttrVisitor.h"
Alexander Kornienkoebc17b52013-01-14 14:07:11 +000018#include "clang/AST/CommentVisitor.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000019#include "clang/AST/DeclCXX.h"
Richard Smith33937e72013-06-22 21:49:40 +000020#include "clang/AST/DeclLookups.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000021#include "clang/AST/DeclObjC.h"
Alexey Bataev958b9e72016-03-31 09:30:50 +000022#include "clang/AST/DeclOpenMP.h"
Alexander Kornienko90ff6072012-12-20 02:09:13 +000023#include "clang/AST/DeclVisitor.h"
Benjamin Kramer31b382e2016-02-01 17:42:01 +000024#include "clang/AST/LocInfoType.h"
Chandler Carruth3a022472012-12-04 09:13:33 +000025#include "clang/AST/StmtVisitor.h"
Stephen Kelly63a6f3a2019-01-12 16:35:37 +000026#include "clang/AST/TemplateArgumentVisitor.h"
Stephen Kellyd8744a72018-12-05 21:12:39 +000027#include "clang/AST/TextNodeDumper.h"
Richard Smithd5e7ff82014-10-31 01:17:45 +000028#include "clang/AST/TypeVisitor.h"
David Majnemerd9b1a4f2015-11-04 03:40:30 +000029#include "clang/Basic/Builtins.h"
Alexander Kornienko90ff6072012-12-20 02:09:13 +000030#include "clang/Basic/Module.h"
Chris Lattner11e30d32007-08-30 06:17:34 +000031#include "clang/Basic/SourceManager.h"
Daniel Dunbar34a96c82009-12-03 09:13:13 +000032#include "llvm/Support/raw_ostream.h"
Chris Lattnercbe4f772007-08-08 22:51:59 +000033using namespace clang;
Alexander Kornienkoebc17b52013-01-14 14:07:11 +000034using namespace clang::comments;
Chris Lattnercbe4f772007-08-08 22:51:59 +000035
36//===----------------------------------------------------------------------===//
Alexander Kornienko18ec81b2012-12-13 13:59:55 +000037// ASTDumper Visitor
Chris Lattnercbe4f772007-08-08 22:51:59 +000038//===----------------------------------------------------------------------===//
39
40namespace {
Stephen Kelly27e948c2018-11-29 19:30:37 +000041
Alexander Kornienko90ff6072012-12-20 02:09:13 +000042 class ASTDumper
Stephen Kellycdbfb302018-12-02 17:30:40 +000043 : public ConstDeclVisitor<ASTDumper>,
44 public ConstStmtVisitor<ASTDumper>,
45 public ConstCommentVisitor<ASTDumper, void, const FullComment *>,
Stephen Kellydb8fac12019-01-11 19:16:01 +000046 public TypeVisitor<ASTDumper>,
Stephen Kelly63a6f3a2019-01-12 16:35:37 +000047 public ConstAttrVisitor<ASTDumper>,
48 public ConstTemplateArgumentVisitor<ASTDumper> {
Stephen Kellycdbfb302018-12-02 17:30:40 +000049
Stephen Kellyd8744a72018-12-05 21:12:39 +000050 TextNodeDumper NodeDumper;
Stephen Kelly0da68ba2018-12-05 20:53:14 +000051
Chris Lattner0e62c1c2011-07-23 10:55:15 +000052 raw_ostream &OS;
Mike Stump11289f42009-09-09 15:08:12 +000053
Richard Smith3a36ac12017-03-09 22:00:01 +000054 /// Indicates whether we should trigger deserialization of nodes that had
55 /// not already been loaded.
56 bool Deserialize = false;
57
Stephen Kellye66308b2018-11-29 19:30:08 +000058 const bool ShowColors;
Richard Trieud215b8d2013-01-26 01:31:20 +000059
Chris Lattnercbe4f772007-08-08 22:51:59 +000060 public:
Alexander Kornienkoebc17b52013-01-14 14:07:11 +000061 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
62 const SourceManager *SM)
Aaron Ballman8c208282017-12-21 21:42:42 +000063 : ASTDumper(OS, Traits, SM,
64 SM && SM->getDiagnostics().getShowColors()) {}
Richard Trieud215b8d2013-01-26 01:31:20 +000065
66 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
67 const SourceManager *SM, bool ShowColors)
Aaron Ballman8c208282017-12-21 21:42:42 +000068 : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
69 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
70 const SourceManager *SM, bool ShowColors,
71 const PrintingPolicy &PrintPolicy)
Stephen Kellyb6d674f2019-01-08 22:32:48 +000072 : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
Stephen Kellyb6318c92019-01-30 19:32:48 +000073 ShowColors(ShowColors) {}
Richard Smith3a36ac12017-03-09 22:00:01 +000074
75 void setDeserialize(bool D) { Deserialize = D; }
Mike Stump11289f42009-09-09 15:08:12 +000076
Alexander Kornienko540bacb2013-02-01 12:35:51 +000077 void dumpDecl(const Decl *D);
Stephen Kelly0df805d2019-01-11 19:11:17 +000078 void dumpStmt(const Stmt *S, StringRef Label = {});
Mike Stump11289f42009-09-09 15:08:12 +000079
Richard Trieude5cc7d2013-01-31 01:44:26 +000080 // Utilities
Richard Smithd5e7ff82014-10-31 01:17:45 +000081 void dumpTypeAsChild(QualType T);
82 void dumpTypeAsChild(const Type *T);
Alexander Kornienko787f4c32012-12-20 11:08:38 +000083 void dumpDeclContext(const DeclContext *DC);
Richard Smith35f986d2014-08-11 22:11:07 +000084 void dumpLookups(const DeclContext *DC, bool DumpDecls);
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000085 void dumpAttr(const Attr *A);
Alexander Kornienko90ff6072012-12-20 02:09:13 +000086
87 // C++ Utilities
Alexander Kornienko787f4c32012-12-20 11:08:38 +000088 void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
89 void dumpTemplateParameters(const TemplateParameterList *TPL);
Alexander Kornienko90ff6072012-12-20 02:09:13 +000090 void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
Stephen Kelly43835952018-12-10 21:03:00 +000091 void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
92 const Decl *From = nullptr,
Stephen Kelly1be0bea2018-12-10 21:04:04 +000093 const char *Label = nullptr);
Alexander Kornienko90ff6072012-12-20 02:09:13 +000094 void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
95 void dumpTemplateArgument(const TemplateArgument &A,
Stephen Kelly43835952018-12-10 21:03:00 +000096 SourceRange R = SourceRange(),
97 const Decl *From = nullptr,
Stephen Kelly1be0bea2018-12-10 21:04:04 +000098 const char *Label = nullptr);
Stephen Kelly24136382018-12-09 13:33:30 +000099 template <typename SpecializationDecl>
100 void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
101 bool DumpExplicitInst,
102 bool DumpRefOnly);
103 template <typename TemplateDecl>
104 void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000105
Douglas Gregor85f3f952015-07-07 03:57:15 +0000106 // Objective-C utilities.
107 void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams);
108
Richard Smithd5e7ff82014-10-31 01:17:45 +0000109 // Types
110 void VisitComplexType(const ComplexType *T) {
111 dumpTypeAsChild(T->getElementType());
112 }
Stephen Kellybc2438d2019-01-14 20:13:09 +0000113 void VisitLocInfoType(const LocInfoType *T) {
114 dumpTypeAsChild(T->getTypeSourceInfo()->getType());
115 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000116 void VisitPointerType(const PointerType *T) {
117 dumpTypeAsChild(T->getPointeeType());
118 }
119 void VisitBlockPointerType(const BlockPointerType *T) {
120 dumpTypeAsChild(T->getPointeeType());
121 }
122 void VisitReferenceType(const ReferenceType *T) {
123 dumpTypeAsChild(T->getPointeeType());
124 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000125 void VisitMemberPointerType(const MemberPointerType *T) {
126 dumpTypeAsChild(T->getClass());
127 dumpTypeAsChild(T->getPointeeType());
128 }
129 void VisitArrayType(const ArrayType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000130 dumpTypeAsChild(T->getElementType());
131 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000132 void VisitVariableArrayType(const VariableArrayType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000133 VisitArrayType(T);
134 dumpStmt(T->getSizeExpr());
135 }
136 void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
Stephen Kellyec42aa02018-12-05 20:34:07 +0000137 dumpTypeAsChild(T->getElementType());
Richard Smithd5e7ff82014-10-31 01:17:45 +0000138 dumpStmt(T->getSizeExpr());
139 }
140 void VisitDependentSizedExtVectorType(
141 const DependentSizedExtVectorType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000142 dumpTypeAsChild(T->getElementType());
143 dumpStmt(T->getSizeExpr());
144 }
145 void VisitVectorType(const VectorType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000146 dumpTypeAsChild(T->getElementType());
147 }
148 void VisitFunctionType(const FunctionType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000149 dumpTypeAsChild(T->getReturnType());
150 }
151 void VisitFunctionProtoType(const FunctionProtoType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000152 VisitFunctionType(T);
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000153 for (const QualType &PT : T->getParamTypes())
Richard Smithd5e7ff82014-10-31 01:17:45 +0000154 dumpTypeAsChild(PT);
Richard Smithd5e7ff82014-10-31 01:17:45 +0000155 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000156 void VisitTypeOfExprType(const TypeOfExprType *T) {
157 dumpStmt(T->getUnderlyingExpr());
158 }
159 void VisitDecltypeType(const DecltypeType *T) {
160 dumpStmt(T->getUnderlyingExpr());
161 }
162 void VisitUnaryTransformType(const UnaryTransformType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000163 dumpTypeAsChild(T->getBaseType());
164 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000165 void VisitAttributedType(const AttributedType *T) {
166 // FIXME: AttrKind
167 dumpTypeAsChild(T->getModifiedType());
168 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000169 void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
170 dumpTypeAsChild(T->getReplacedParameter());
171 }
172 void VisitSubstTemplateTypeParmPackType(
173 const SubstTemplateTypeParmPackType *T) {
174 dumpTypeAsChild(T->getReplacedParameter());
175 dumpTemplateArgument(T->getArgumentPack());
176 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000177 void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000178 for (const auto &Arg : *T)
Richard Smithd5e7ff82014-10-31 01:17:45 +0000179 dumpTemplateArgument(Arg);
180 if (T->isTypeAlias())
181 dumpTypeAsChild(T->getAliasedType());
182 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000183 void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
184 dumpTypeAsChild(T->getPointeeType());
185 }
186 void VisitAtomicType(const AtomicType *T) {
187 dumpTypeAsChild(T->getValueType());
188 }
Xiuli Pan2d12e652016-05-03 05:37:07 +0000189 void VisitPipeType(const PipeType *T) {
190 dumpTypeAsChild(T->getElementType());
191 }
Richard Smithd5e7ff82014-10-31 01:17:45 +0000192 void VisitAdjustedType(const AdjustedType *T) {
193 dumpTypeAsChild(T->getOriginalType());
194 }
195 void VisitPackExpansionType(const PackExpansionType *T) {
Richard Smithd5e7ff82014-10-31 01:17:45 +0000196 if (!T->isSugared())
197 dumpTypeAsChild(T->getPattern());
198 }
199 // FIXME: ElaboratedType, DependentNameType,
200 // DependentTemplateSpecializationType, ObjCObjectType
201
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000202 // Decls
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000203 void VisitTypedefDecl(const TypedefDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000204 void VisitEnumConstantDecl(const EnumConstantDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000205 void VisitFunctionDecl(const FunctionDecl *D);
206 void VisitFieldDecl(const FieldDecl *D);
207 void VisitVarDecl(const VarDecl *D);
Richard Smithbdb84f32016-07-22 23:36:59 +0000208 void VisitDecompositionDecl(const DecompositionDecl *D);
Richard Smith7873de02016-08-11 22:25:46 +0000209 void VisitBindingDecl(const BindingDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000210 void VisitFileScopeAsmDecl(const FileScopeAsmDecl *D);
Alexey Bataev958b9e72016-03-31 09:30:50 +0000211 void VisitCapturedDecl(const CapturedDecl *D);
212
213 // OpenMP decls
214 void VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D);
215 void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D);
216 void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000217
218 // C++ Decls
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000219 void VisitTypeAliasDecl(const TypeAliasDecl *D);
220 void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000221 void VisitStaticAssertDecl(const StaticAssertDecl *D);
222 void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
223 void VisitClassTemplateDecl(const ClassTemplateDecl *D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000224 void VisitClassTemplateSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000225 const ClassTemplateSpecializationDecl *D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000226 void VisitClassTemplatePartialSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000227 const ClassTemplatePartialSpecializationDecl *D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000228 void VisitClassScopeFunctionSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000229 const ClassScopeFunctionSpecializationDecl *D);
David Majnemerd9b1a4f2015-11-04 03:40:30 +0000230 void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
Richard Smithd25789a2013-09-18 01:36:02 +0000231 void VisitVarTemplateDecl(const VarTemplateDecl *D);
232 void VisitVarTemplateSpecializationDecl(
233 const VarTemplateSpecializationDecl *D);
234 void VisitVarTemplatePartialSpecializationDecl(
235 const VarTemplatePartialSpecializationDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000236 void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
237 void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
238 void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000239 void VisitUsingShadowDecl(const UsingShadowDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000240 void VisitFriendDecl(const FriendDecl *D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000241
242 // ObjC Decls
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000243 void VisitObjCMethodDecl(const ObjCMethodDecl *D);
244 void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000245 void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
246 void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
Stephen Kellyfbf424e2019-01-15 20:41:37 +0000247 void Visit(const BlockDecl::Capture &C);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000248 void VisitBlockDecl(const BlockDecl *D);
Mike Stump11289f42009-09-09 15:08:12 +0000249
Chris Lattner84ca3762007-08-30 01:00:35 +0000250 // Stmts.
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000251 void VisitDeclStmt(const DeclStmt *Node);
252 void VisitAttributedStmt(const AttributedStmt *Node);
Pavel Labath1ef83422013-09-04 14:35:00 +0000253 void VisitCXXCatchStmt(const CXXCatchStmt *Node);
Alexey Bataev958b9e72016-03-31 09:30:50 +0000254 void VisitCapturedStmt(const CapturedStmt *Node);
255
256 // OpenMP
Stephen Kelly3cdd1a72019-01-15 20:31:31 +0000257 void Visit(const OMPClause *C);
Alexey Bataev958b9e72016-03-31 09:30:50 +0000258 void VisitOMPExecutableDirective(const OMPExecutableDirective *Node);
Mike Stump11289f42009-09-09 15:08:12 +0000259
Chris Lattner84ca3762007-08-30 01:00:35 +0000260 // Exprs
Richard Smithf0514962014-06-03 08:24:28 +0000261 void VisitInitListExpr(const InitListExpr *ILE);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000262 void VisitBlockExpr(const BlockExpr *Node);
263 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
Stephen Kellyfbf40f42019-01-29 22:22:55 +0000264 void Visit(const GenericSelectionExpr::ConstAssociation &A);
Richard Smith01ccebf2018-01-05 21:31:07 +0000265 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
Chris Lattner84ca3762007-08-30 01:00:35 +0000266
267 // C++
Faisal Vali2b391ab2013-09-26 19:54:12 +0000268 void VisitLambdaExpr(const LambdaExpr *Node) {
Faisal Vali2b391ab2013-09-26 19:54:12 +0000269 dumpDecl(Node->getLambdaClass());
270 }
Serge Pavlov6b926032015-02-16 19:58:41 +0000271 void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
Mike Stump11289f42009-09-09 15:08:12 +0000272
Chris Lattner84ca3762007-08-30 01:00:35 +0000273 // ObjC
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000274 void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000275
276 // Comments.
Stephen Kellycdbfb302018-12-02 17:30:40 +0000277 void dumpComment(const Comment *C, const FullComment *FC);
Stephen Kellydb8fac12019-01-11 19:16:01 +0000278
Stephen Kelly63a6f3a2019-01-12 16:35:37 +0000279 void VisitExpressionTemplateArgument(const TemplateArgument &TA) {
280 dumpStmt(TA.getAsExpr());
281 }
282 void VisitPackTemplateArgument(const TemplateArgument &TA) {
Stephen Kelly4b5e7cd2019-01-14 19:50:34 +0000283 for (const auto &TArg : TA.pack_elements())
Stephen Kelly63a6f3a2019-01-12 16:35:37 +0000284 dumpTemplateArgument(TArg);
285 }
286
Stephen Kellydb8fac12019-01-11 19:16:01 +0000287// Implements Visit methods for Attrs.
288#include "clang/AST/AttrNodeTraverse.inc"
Chris Lattnercbe4f772007-08-08 22:51:59 +0000289 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000290}
Chris Lattnercbe4f772007-08-08 22:51:59 +0000291
292//===----------------------------------------------------------------------===//
Chris Lattner11e30d32007-08-30 06:17:34 +0000293// Utilities
294//===----------------------------------------------------------------------===//
295
Richard Smithd5e7ff82014-10-31 01:17:45 +0000296void ASTDumper::dumpTypeAsChild(QualType T) {
297 SplitQualType SQT = T.split();
298 if (!SQT.Quals.hasQualifiers())
299 return dumpTypeAsChild(SQT.Ty);
300
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000301 NodeDumper.AddChild([=] {
Stephen Kelly58c65042019-01-14 20:15:29 +0000302 NodeDumper.Visit(T);
Richard Smithd5e7ff82014-10-31 01:17:45 +0000303 dumpTypeAsChild(T.split().Ty);
304 });
305}
306
307void ASTDumper::dumpTypeAsChild(const Type *T) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000308 NodeDumper.AddChild([=] {
Stephen Kelly449fa762019-01-14 20:11:02 +0000309 NodeDumper.Visit(T);
310 if (!T)
Richard Smithd5e7ff82014-10-31 01:17:45 +0000311 return;
Stephen Kelly449fa762019-01-14 20:11:02 +0000312 TypeVisitor<ASTDumper>::Visit(T);
Richard Smithd5e7ff82014-10-31 01:17:45 +0000313
314 QualType SingleStepDesugar =
315 T->getLocallyUnqualifiedSingleStepDesugaredType();
316 if (SingleStepDesugar != QualType(T, 0))
Richard Smithd5e7ff82014-10-31 01:17:45 +0000317 dumpTypeAsChild(SingleStepDesugar);
318 });
319}
320
Alexander Kornienko787f4c32012-12-20 11:08:38 +0000321void ASTDumper::dumpDeclContext(const DeclContext *DC) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000322 if (!DC)
323 return;
Richard Smithdcc2c452014-03-17 23:00:06 +0000324
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000325 for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
Richard Smithf7514452014-10-30 21:02:37 +0000326 dumpDecl(D);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000327}
328
Richard Smith35f986d2014-08-11 22:11:07 +0000329void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000330 NodeDumper.AddChild([=] {
Richard Smithf7514452014-10-30 21:02:37 +0000331 OS << "StoredDeclsMap ";
Stephen Kellyd8744a72018-12-05 21:12:39 +0000332 NodeDumper.dumpBareDeclRef(cast<Decl>(DC));
Richard Smith33937e72013-06-22 21:49:40 +0000333
Richard Smithf7514452014-10-30 21:02:37 +0000334 const DeclContext *Primary = DC->getPrimaryContext();
335 if (Primary != DC) {
336 OS << " primary";
Stephen Kellyd8744a72018-12-05 21:12:39 +0000337 NodeDumper.dumpPointer(cast<Decl>(Primary));
Richard Smith33937e72013-06-22 21:49:40 +0000338 }
339
Richard Smithf7514452014-10-30 21:02:37 +0000340 bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
Richard Smith35f986d2014-08-11 22:11:07 +0000341
Sam McCall091b1ef2018-01-16 12:33:46 +0000342 auto Range = Deserialize
343 ? Primary->lookups()
344 : Primary->noload_lookups(/*PreserveInternalState=*/true);
345 for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {
Richard Smithf7514452014-10-30 21:02:37 +0000346 DeclarationName Name = I.getLookupName();
Richard Smith3a36ac12017-03-09 22:00:01 +0000347 DeclContextLookupResult R = *I;
Richard Smith35f986d2014-08-11 22:11:07 +0000348
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000349 NodeDumper.AddChild([=] {
Richard Smithf7514452014-10-30 21:02:37 +0000350 OS << "DeclarationName ";
351 {
Stephen Kelly27e948c2018-11-29 19:30:37 +0000352 ColorScope Color(OS, ShowColors, DeclNameColor);
Richard Smithf7514452014-10-30 21:02:37 +0000353 OS << '\'' << Name << '\'';
354 }
Richard Smith35f986d2014-08-11 22:11:07 +0000355
Richard Smithf7514452014-10-30 21:02:37 +0000356 for (DeclContextLookupResult::iterator RI = R.begin(), RE = R.end();
357 RI != RE; ++RI) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000358 NodeDumper.AddChild([=] {
Stephen Kellyd8744a72018-12-05 21:12:39 +0000359 NodeDumper.dumpBareDeclRef(*RI);
Richard Smithf7514452014-10-30 21:02:37 +0000360
361 if ((*RI)->isHidden())
362 OS << " hidden";
363
364 // If requested, dump the redecl chain for this lookup.
365 if (DumpDecls) {
366 // Dump earliest decl first.
367 std::function<void(Decl *)> DumpWithPrev = [&](Decl *D) {
368 if (Decl *Prev = D->getPreviousDecl())
369 DumpWithPrev(Prev);
370 dumpDecl(D);
371 };
372 DumpWithPrev(*RI);
373 }
374 });
375 }
376 });
Richard Smith33937e72013-06-22 21:49:40 +0000377 }
Richard Smith33937e72013-06-22 21:49:40 +0000378
Richard Smithf7514452014-10-30 21:02:37 +0000379 if (HasUndeserializedLookups) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000380 NodeDumper.AddChild([=] {
Stephen Kelly27e948c2018-11-29 19:30:37 +0000381 ColorScope Color(OS, ShowColors, UndeserializedColor);
Richard Smithf7514452014-10-30 21:02:37 +0000382 OS << "<undeserialized lookups>";
383 });
384 }
385 });
Richard Smith33937e72013-06-22 21:49:40 +0000386}
387
Alexander Kornienko5bc364e2013-01-07 17:53:08 +0000388void ASTDumper::dumpAttr(const Attr *A) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000389 NodeDumper.AddChild([=] {
Stephen Kellydb8fac12019-01-11 19:16:01 +0000390 NodeDumper.Visit(A);
391 ConstAttrVisitor<ASTDumper>::Visit(A);
Richard Smithf7514452014-10-30 21:02:37 +0000392 });
Alexander Kornienko5bc364e2013-01-07 17:53:08 +0000393}
394
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000395//===----------------------------------------------------------------------===//
396// C++ Utilities
397//===----------------------------------------------------------------------===//
398
Alexander Kornienko787f4c32012-12-20 11:08:38 +0000399void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000400 NodeDumper.AddChild([=] {
Stephen Kelly0e050fa2019-01-15 20:17:33 +0000401 NodeDumper.Visit(Init);
Richard Smithf7514452014-10-30 21:02:37 +0000402 dumpStmt(Init->getInit());
403 });
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000404}
405
Alexander Kornienko787f4c32012-12-20 11:08:38 +0000406void ASTDumper::dumpTemplateParameters(const TemplateParameterList *TPL) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000407 if (!TPL)
408 return;
409
Stephen Kelly8805f672019-01-19 09:57:59 +0000410 for (const auto &TP : *TPL)
411 dumpDecl(TP);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000412}
413
414void ASTDumper::dumpTemplateArgumentListInfo(
415 const TemplateArgumentListInfo &TALI) {
Stephen Kelly8805f672019-01-19 09:57:59 +0000416 for (const auto &TA : TALI.arguments())
417 dumpTemplateArgumentLoc(TA);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000418}
419
Stephen Kelly43835952018-12-10 21:03:00 +0000420void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
Stephen Kelly1be0bea2018-12-10 21:04:04 +0000421 const Decl *From, const char *Label) {
422 dumpTemplateArgument(A.getArgument(), A.getSourceRange(), From, Label);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000423}
424
425void ASTDumper::dumpTemplateArgumentList(const TemplateArgumentList &TAL) {
426 for (unsigned i = 0, e = TAL.size(); i < e; ++i)
427 dumpTemplateArgument(TAL[i]);
428}
429
Stephen Kelly43835952018-12-10 21:03:00 +0000430void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R,
Stephen Kelly1be0bea2018-12-10 21:04:04 +0000431 const Decl *From, const char *Label) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000432 NodeDumper.AddChild([=] {
Stephen Kelly63a6f3a2019-01-12 16:35:37 +0000433 NodeDumper.Visit(A, R, From, Label);
434 ConstTemplateArgumentVisitor<ASTDumper>::Visit(A);
Richard Smithf7514452014-10-30 21:02:37 +0000435 });
Alexander Kornienko61c93bd2012-12-11 15:28:09 +0000436}
437
Chris Lattner11e30d32007-08-30 06:17:34 +0000438//===----------------------------------------------------------------------===//
Douglas Gregor85f3f952015-07-07 03:57:15 +0000439// Objective-C Utilities
440//===----------------------------------------------------------------------===//
441void ASTDumper::dumpObjCTypeParamList(const ObjCTypeParamList *typeParams) {
442 if (!typeParams)
443 return;
444
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000445 for (const auto &typeParam : *typeParams) {
Douglas Gregor85f3f952015-07-07 03:57:15 +0000446 dumpDecl(typeParam);
447 }
448}
449
450//===----------------------------------------------------------------------===//
Alexander Kornienko61c93bd2012-12-11 15:28:09 +0000451// Decl dumping methods.
Chris Lattnercbe4f772007-08-08 22:51:59 +0000452//===----------------------------------------------------------------------===//
453
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000454void ASTDumper::dumpDecl(const Decl *D) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000455 NodeDumper.AddChild([=] {
Stephen Kellyd83fe892019-01-15 09:35:52 +0000456 NodeDumper.Visit(D);
457 if (!D)
Richard Smithf7514452014-10-30 21:02:37 +0000458 return;
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000459
Richard Smithf7514452014-10-30 21:02:37 +0000460 ConstDeclVisitor<ASTDumper>::Visit(D);
Richard Trieude5cc7d2013-01-31 01:44:26 +0000461
Stephen Kelly8805f672019-01-19 09:57:59 +0000462 for (const auto &A : D->attrs())
463 dumpAttr(A);
Richard Trieude5cc7d2013-01-31 01:44:26 +0000464
Richard Smithf7514452014-10-30 21:02:37 +0000465 if (const FullComment *Comment =
466 D->getASTContext().getLocalCommentForDeclUncached(D))
Stephen Kelly570b2972018-12-09 13:18:55 +0000467 dumpComment(Comment, Comment);
Richard Trieude5cc7d2013-01-31 01:44:26 +0000468
Richard Smithf7514452014-10-30 21:02:37 +0000469 // Decls within functions are visited by the body.
Stephen Kelly39271a12018-12-09 13:20:43 +0000470 if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D)) {
Stephen Kelly1e07f4e2019-01-18 22:15:09 +0000471 if (const auto *DC = dyn_cast<DeclContext>(D))
Stephen Kelly39271a12018-12-09 13:20:43 +0000472 dumpDeclContext(DC);
473 }
Richard Smithf7514452014-10-30 21:02:37 +0000474 });
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000475}
476
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000477void ASTDumper::VisitTypedefDecl(const TypedefDecl *D) {
Richard Smithba3a4f92016-01-12 21:59:26 +0000478 dumpTypeAsChild(D->getUnderlyingType());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000479}
480
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000481void ASTDumper::VisitEnumConstantDecl(const EnumConstantDecl *D) {
Richard Smithf7514452014-10-30 21:02:37 +0000482 if (const Expr *Init = D->getInitExpr())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000483 dumpStmt(Init);
484}
485
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000486void ASTDumper::VisitFunctionDecl(const FunctionDecl *D) {
Stephen Kellye80e4cb2019-01-15 23:05:11 +0000487 if (const auto *FTSI = D->getTemplateSpecializationInfo())
Stephen Kelly42d99502019-01-15 22:50:37 +0000488 dumpTemplateArgumentList(*FTSI->TemplateArguments);
489
Stephen Kellybbd08cc2019-01-18 22:00:16 +0000490 if (D->param_begin())
491 for (const auto *Parameter : D->parameters())
Stephen Kelly42d99502019-01-15 22:50:37 +0000492 dumpDecl(Parameter);
493
Stephen Kellye80e4cb2019-01-15 23:05:11 +0000494 if (const auto *C = dyn_cast<CXXConstructorDecl>(D))
495 for (const auto *I : C->inits())
496 dumpCXXCtorInitializer(I);
Stephen Kelly42d99502019-01-15 22:50:37 +0000497
Richard Smithf7514452014-10-30 21:02:37 +0000498 if (D->doesThisDeclarationHaveABody())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000499 dumpStmt(D->getBody());
500}
501
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000502void ASTDumper::VisitFieldDecl(const FieldDecl *D) {
Richard Smithf7514452014-10-30 21:02:37 +0000503 if (D->isBitField())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000504 dumpStmt(D->getBitWidth());
Richard Smithf7514452014-10-30 21:02:37 +0000505 if (Expr *Init = D->getInClassInitializer())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000506 dumpStmt(Init);
507}
508
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000509void ASTDumper::VisitVarDecl(const VarDecl *D) {
Stephen Kellyb6318c92019-01-30 19:32:48 +0000510 if (D->hasInit())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000511 dumpStmt(D->getInit());
512}
513
Richard Smithbdb84f32016-07-22 23:36:59 +0000514void ASTDumper::VisitDecompositionDecl(const DecompositionDecl *D) {
515 VisitVarDecl(D);
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000516 for (const auto *B : D->bindings())
Richard Smithbdb84f32016-07-22 23:36:59 +0000517 dumpDecl(B);
518}
519
Richard Smith7873de02016-08-11 22:25:46 +0000520void ASTDumper::VisitBindingDecl(const BindingDecl *D) {
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000521 if (const auto *E = D->getBinding())
Richard Smith7873de02016-08-11 22:25:46 +0000522 dumpStmt(E);
523}
524
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000525void ASTDumper::VisitFileScopeAsmDecl(const FileScopeAsmDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000526 dumpStmt(D->getAsmString());
527}
528
Alexey Bataev958b9e72016-03-31 09:30:50 +0000529void ASTDumper::VisitCapturedDecl(const CapturedDecl *D) {
530 dumpStmt(D->getBody());
531}
532
533//===----------------------------------------------------------------------===//
534// OpenMP Declarations
535//===----------------------------------------------------------------------===//
536
537void ASTDumper::VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000538 for (const auto *E : D->varlists())
Alexey Bataev958b9e72016-03-31 09:30:50 +0000539 dumpStmt(E);
540}
541
542void ASTDumper::VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D) {
Stephen Kelly266dc192018-12-10 20:53:39 +0000543 dumpStmt(D->getCombiner());
544 if (const auto *Initializer = D->getInitializer())
545 dumpStmt(Initializer);
Alexey Bataev958b9e72016-03-31 09:30:50 +0000546}
547
548void ASTDumper::VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D) {
Alexey Bataev958b9e72016-03-31 09:30:50 +0000549 dumpStmt(D->getInit());
550}
Nico Webercbbaeb12016-03-02 19:28:54 +0000551
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000552//===----------------------------------------------------------------------===//
553// C++ Declarations
554//===----------------------------------------------------------------------===//
555
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000556void ASTDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
Richard Smithba3a4f92016-01-12 21:59:26 +0000557 dumpTypeAsChild(D->getUnderlyingType());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000558}
559
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000560void ASTDumper::VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000561 dumpTemplateParameters(D->getTemplateParameters());
562 dumpDecl(D->getTemplatedDecl());
563}
564
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000565void ASTDumper::VisitStaticAssertDecl(const StaticAssertDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000566 dumpStmt(D->getAssertExpr());
567 dumpStmt(D->getMessage());
568}
569
Stephen Kelly24136382018-12-09 13:33:30 +0000570template <typename SpecializationDecl>
571void ASTDumper::dumpTemplateDeclSpecialization(const SpecializationDecl *D,
572 bool DumpExplicitInst,
573 bool DumpRefOnly) {
Richard Smithcbdf7332014-03-18 02:07:28 +0000574 bool DumpedAny = false;
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000575 for (const auto *RedeclWithBadType : D->redecls()) {
Richard Smithcbdf7332014-03-18 02:07:28 +0000576 // FIXME: The redecls() range sometimes has elements of a less-specific
577 // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
578 // us TagDecls, and should give CXXRecordDecls).
579 auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
580 if (!Redecl) {
581 // Found the injected-class-name for a class template. This will be dumped
582 // as part of its surrounding class so we don't need to dump it here.
583 assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
584 "expected an injected-class-name");
585 continue;
586 }
587
588 switch (Redecl->getTemplateSpecializationKind()) {
589 case TSK_ExplicitInstantiationDeclaration:
590 case TSK_ExplicitInstantiationDefinition:
591 if (!DumpExplicitInst)
592 break;
Adrian Prantlf3b3ccd2017-12-19 22:06:11 +0000593 LLVM_FALLTHROUGH;
Richard Smithcbdf7332014-03-18 02:07:28 +0000594 case TSK_Undeclared:
595 case TSK_ImplicitInstantiation:
Richard Smithf7514452014-10-30 21:02:37 +0000596 if (DumpRefOnly)
Stephen Kellyd186dbc2019-01-08 23:11:24 +0000597 NodeDumper.dumpDeclRef(Redecl);
Richard Smithf7514452014-10-30 21:02:37 +0000598 else
599 dumpDecl(Redecl);
Richard Smithcbdf7332014-03-18 02:07:28 +0000600 DumpedAny = true;
601 break;
602 case TSK_ExplicitSpecialization:
603 break;
604 }
605 }
606
607 // Ensure we dump at least one decl for each specialization.
608 if (!DumpedAny)
Stephen Kellyd186dbc2019-01-08 23:11:24 +0000609 NodeDumper.dumpDeclRef(D);
Richard Smithcbdf7332014-03-18 02:07:28 +0000610}
611
Stephen Kelly24136382018-12-09 13:33:30 +0000612template <typename TemplateDecl>
613void ASTDumper::dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000614 dumpTemplateParameters(D->getTemplateParameters());
Richard Smithdcc2c452014-03-17 23:00:06 +0000615
Richard Smithf7514452014-10-30 21:02:37 +0000616 dumpDecl(D->getTemplatedDecl());
Richard Smithdcc2c452014-03-17 23:00:06 +0000617
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000618 for (const auto *Child : D->specializations())
Stephen Kelly24136382018-12-09 13:33:30 +0000619 dumpTemplateDeclSpecialization(Child, DumpExplicitInst,
620 !D->isCanonicalDecl());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000621}
622
Richard Smith20ade552014-03-17 23:34:53 +0000623void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
624 // FIXME: We don't add a declaration of a function template specialization
625 // to its context when it's explicitly instantiated, so dump explicit
626 // instantiations when we dump the template itself.
Stephen Kelly24136382018-12-09 13:33:30 +0000627 dumpTemplateDecl(D, true);
Richard Smith20ade552014-03-17 23:34:53 +0000628}
629
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000630void ASTDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
Stephen Kelly24136382018-12-09 13:33:30 +0000631 dumpTemplateDecl(D, false);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000632}
633
634void ASTDumper::VisitClassTemplateSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000635 const ClassTemplateSpecializationDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000636 dumpTemplateArgumentList(D->getTemplateArgs());
637}
638
639void ASTDumper::VisitClassTemplatePartialSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000640 const ClassTemplatePartialSpecializationDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000641 VisitClassTemplateSpecializationDecl(D);
642 dumpTemplateParameters(D->getTemplateParameters());
643}
644
645void ASTDumper::VisitClassScopeFunctionSpecializationDecl(
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000646 const ClassScopeFunctionSpecializationDecl *D) {
Richard Smithc660c8f2018-03-16 13:36:56 +0000647 dumpDecl(D->getSpecialization());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000648 if (D->hasExplicitTemplateArgs())
649 dumpTemplateArgumentListInfo(D->templateArgs());
650}
651
Richard Smithd25789a2013-09-18 01:36:02 +0000652void ASTDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) {
Stephen Kelly24136382018-12-09 13:33:30 +0000653 dumpTemplateDecl(D, false);
Richard Smithd25789a2013-09-18 01:36:02 +0000654}
655
David Majnemerd9b1a4f2015-11-04 03:40:30 +0000656void ASTDumper::VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D) {
David Majnemerd9b1a4f2015-11-04 03:40:30 +0000657 dumpTemplateParameters(D->getTemplateParameters());
658}
659
Richard Smithd25789a2013-09-18 01:36:02 +0000660void ASTDumper::VisitVarTemplateSpecializationDecl(
661 const VarTemplateSpecializationDecl *D) {
662 dumpTemplateArgumentList(D->getTemplateArgs());
663 VisitVarDecl(D);
664}
665
666void ASTDumper::VisitVarTemplatePartialSpecializationDecl(
667 const VarTemplatePartialSpecializationDecl *D) {
668 dumpTemplateParameters(D->getTemplateParameters());
669 VisitVarTemplateSpecializationDecl(D);
670}
671
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000672void ASTDumper::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
Richard Smithf7514452014-10-30 21:02:37 +0000673 if (D->hasDefaultArgument())
Stephen Kelly43835952018-12-10 21:03:00 +0000674 dumpTemplateArgument(D->getDefaultArgument(), SourceRange(),
675 D->getDefaultArgStorage().getInheritedFrom(),
676 D->defaultArgumentWasInherited() ? "inherited from"
677 : "previous");
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000678}
679
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000680void ASTDumper::VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
Richard Smithf7514452014-10-30 21:02:37 +0000681 if (D->hasDefaultArgument())
Stephen Kelly43835952018-12-10 21:03:00 +0000682 dumpTemplateArgument(D->getDefaultArgument(), SourceRange(),
683 D->getDefaultArgStorage().getInheritedFrom(),
684 D->defaultArgumentWasInherited() ? "inherited from"
685 : "previous");
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000686}
687
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000688void ASTDumper::VisitTemplateTemplateParmDecl(
689 const TemplateTemplateParmDecl *D) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000690 dumpTemplateParameters(D->getTemplateParameters());
Richard Smithf7514452014-10-30 21:02:37 +0000691 if (D->hasDefaultArgument())
Stephen Kelly43835952018-12-10 21:03:00 +0000692 dumpTemplateArgumentLoc(
693 D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(),
694 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000695}
696
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000697void ASTDumper::VisitUsingShadowDecl(const UsingShadowDecl *D) {
Richard Smithba3a4f92016-01-12 21:59:26 +0000698 if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl()))
699 dumpTypeAsChild(TD->getTypeForDecl());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000700}
701
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000702void ASTDumper::VisitFriendDecl(const FriendDecl *D) {
Stephen Kellyb6318c92019-01-30 19:32:48 +0000703 if (!D->getFriendType())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000704 dumpDecl(D->getFriendDecl());
705}
706
707//===----------------------------------------------------------------------===//
708// Obj-C Declarations
709//===----------------------------------------------------------------------===//
710
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000711void ASTDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
Stephen Kellyf4129fd2019-01-18 22:14:59 +0000712 if (D->isThisDeclarationADefinition())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000713 dumpDeclContext(D);
Stephen Kellyf4129fd2019-01-18 22:14:59 +0000714 else
David Majnemera3debed2016-06-24 05:33:44 +0000715 for (const ParmVarDecl *Parameter : D->parameters())
716 dumpDecl(Parameter);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000717
Richard Smithf7514452014-10-30 21:02:37 +0000718 if (D->hasBody())
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000719 dumpStmt(D->getBody());
720}
721
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000722void ASTDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
Stephen Kellya4fd3812019-01-15 23:07:30 +0000723 dumpObjCTypeParamList(D->getTypeParamList());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000724}
725
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000726void ASTDumper::VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
Stephen Kellya4fd3812019-01-15 23:07:30 +0000727 dumpObjCTypeParamList(D->getTypeParamListAsWritten());
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000728}
729
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000730void ASTDumper::VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {
Stephen Kelly8805f672019-01-19 09:57:59 +0000731 for (const auto &I : D->inits())
732 dumpCXXCtorInitializer(I);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000733}
734
Stephen Kellyfbf424e2019-01-15 20:41:37 +0000735void ASTDumper::Visit(const BlockDecl::Capture &C) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000736 NodeDumper.AddChild([=] {
Stephen Kellyfbf424e2019-01-15 20:41:37 +0000737 NodeDumper.Visit(C);
738 if (C.hasCopyExpr())
739 dumpStmt(C.getCopyExpr());
740 });
741}
742
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000743void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000744 for (const auto &I : D->parameters())
Aaron Ballmanb2b8b1d2014-03-07 16:09:59 +0000745 dumpDecl(I);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000746
Stephen Kellyfbf424e2019-01-15 20:41:37 +0000747 for (const auto &I : D->captures())
748 Visit(I);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000749 dumpStmt(D->getBody());
Chris Lattnercbe4f772007-08-08 22:51:59 +0000750}
751
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000752//===----------------------------------------------------------------------===//
Alexander Kornienko61c93bd2012-12-11 15:28:09 +0000753// Stmt dumping methods.
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000754//===----------------------------------------------------------------------===//
755
Stephen Kelly0df805d2019-01-11 19:11:17 +0000756void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000757 NodeDumper.AddChild(Label, [=] {
Stephen Kelly07b76d22019-01-12 16:53:27 +0000758 NodeDumper.Visit(S);
759
Richard Smithf7514452014-10-30 21:02:37 +0000760 if (!S) {
Richard Smithf7514452014-10-30 21:02:37 +0000761 return;
762 }
Stephen Kelly50e82872018-12-06 23:33:33 +0000763
Richard Smithf7514452014-10-30 21:02:37 +0000764 ConstStmtVisitor<ASTDumper>::Visit(S);
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000765
Stephen Kelly91f9c9c2018-12-03 21:05:52 +0000766 // Some statements have custom mechanisms for dumping their children.
767 if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S)) {
768 return;
769 }
770
Benjamin Kramer642f1732015-07-02 21:03:14 +0000771 for (const Stmt *SubStmt : S->children())
772 dumpStmt(SubStmt);
Richard Smithf7514452014-10-30 21:02:37 +0000773 });
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000774}
775
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000776void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
Stephen Kelly8805f672019-01-19 09:57:59 +0000777 for (const auto &D : Node->decls())
778 dumpDecl(D);
Ted Kremenek433a4922007-12-12 06:59:42 +0000779}
780
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000781void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
Stephen Kelly8805f672019-01-19 09:57:59 +0000782 for (const auto *A : Node->getAttrs())
783 dumpAttr(A);
Alexander Kornienko5bc364e2013-01-07 17:53:08 +0000784}
785
Pavel Labath1ef83422013-09-04 14:35:00 +0000786void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {
Pavel Labath1ef83422013-09-04 14:35:00 +0000787 dumpDecl(Node->getExceptionDecl());
788}
789
Alexey Bataev958b9e72016-03-31 09:30:50 +0000790void ASTDumper::VisitCapturedStmt(const CapturedStmt *Node) {
Alexey Bataev958b9e72016-03-31 09:30:50 +0000791 dumpDecl(Node->getCapturedDecl());
792}
793
794//===----------------------------------------------------------------------===//
795// OpenMP dumping methods.
796//===----------------------------------------------------------------------===//
797
Stephen Kelly3cdd1a72019-01-15 20:31:31 +0000798void ASTDumper::Visit(const OMPClause *C) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000799 NodeDumper.AddChild([=] {
Stephen Kelly3cdd1a72019-01-15 20:31:31 +0000800 NodeDumper.Visit(C);
Stephen Kellyaaebc5f2019-01-19 09:57:51 +0000801 for (const auto *S : C->children())
Stephen Kelly3cdd1a72019-01-15 20:31:31 +0000802 dumpStmt(S);
803 });
804}
805
Alexey Bataev958b9e72016-03-31 09:30:50 +0000806void ASTDumper::VisitOMPExecutableDirective(
807 const OMPExecutableDirective *Node) {
Stephen Kelly3cdd1a72019-01-15 20:31:31 +0000808 for (const auto *C : Node->clauses())
809 Visit(C);
Alexey Bataev958b9e72016-03-31 09:30:50 +0000810}
811
Chris Lattnercbe4f772007-08-08 22:51:59 +0000812//===----------------------------------------------------------------------===//
Alexander Kornienko61c93bd2012-12-11 15:28:09 +0000813// Expr dumping methods.
Chris Lattnercbe4f772007-08-08 22:51:59 +0000814//===----------------------------------------------------------------------===//
815
Chris Lattner84ca3762007-08-30 01:00:35 +0000816
Richard Smithf0514962014-06-03 08:24:28 +0000817void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) {
Richard Smithf0514962014-06-03 08:24:28 +0000818 if (auto *Filler = ILE->getArrayFiller()) {
Stephen Kelly0df805d2019-01-11 19:11:17 +0000819 dumpStmt(Filler, "array_filler");
Richard Smithf0514962014-06-03 08:24:28 +0000820 }
Richard Smithf0514962014-06-03 08:24:28 +0000821}
822
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000823void ASTDumper::VisitBlockExpr(const BlockExpr *Node) {
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000824 dumpDecl(Node->getBlockDecl());
John McCall351762c2011-02-07 10:33:21 +0000825}
826
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000827void ASTDumper::VisitOpaqueValueExpr(const OpaqueValueExpr *Node) {
Richard Smithf7514452014-10-30 21:02:37 +0000828 if (Expr *Source = Node->getSourceExpr())
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000829 dumpStmt(Source);
John McCallfe96e0b2011-11-06 09:01:30 +0000830}
831
Stephen Kellyfbf40f42019-01-29 22:22:55 +0000832void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000833 NodeDumper.AddChild([=] {
Stephen Kellyfbf40f42019-01-29 22:22:55 +0000834 NodeDumper.Visit(A);
835 if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
836 dumpTypeAsChild(TSI->getType());
837 dumpStmt(A.getAssociationExpr());
838 });
839}
840
Richard Smith01ccebf2018-01-05 21:31:07 +0000841void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
Richard Smith01ccebf2018-01-05 21:31:07 +0000842 dumpStmt(E->getControllingExpr());
843 dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
844
Bruno Ricci1ec7fd32019-01-29 12:57:11 +0000845 for (const auto &Assoc : E->associations()) {
Stephen Kellyfbf40f42019-01-29 22:22:55 +0000846 Visit(Assoc);
Richard Smith01ccebf2018-01-05 21:31:07 +0000847 }
848}
849
Chris Lattner8f184b12007-08-09 18:03:18 +0000850//===----------------------------------------------------------------------===//
851// C++ Expressions
852//===----------------------------------------------------------------------===//
Chris Lattnercbe4f772007-08-08 22:51:59 +0000853
Serge Pavlov6b926032015-02-16 19:58:41 +0000854void ASTDumper::VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {
Richard Smithd784e682015-09-23 21:41:42 +0000855 if (Node->isPartiallySubstituted())
856 for (const auto &A : Node->getPartialArguments())
857 dumpTemplateArgument(A);
Serge Pavlov6b926032015-02-16 19:58:41 +0000858}
859
Anders Carlsson76f4a902007-08-21 17:43:55 +0000860//===----------------------------------------------------------------------===//
861// Obj-C Expressions
862//===----------------------------------------------------------------------===//
863
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000864void ASTDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000865 if (const VarDecl *CatchParam = Node->getCatchParamDecl())
Alexander Kornienko7bd0f9b2012-12-11 15:20:44 +0000866 dumpDecl(CatchParam);
Ted Kremeneke65b0862012-03-06 20:05:56 +0000867}
868
Chris Lattnercbe4f772007-08-08 22:51:59 +0000869//===----------------------------------------------------------------------===//
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000870// Comments
871//===----------------------------------------------------------------------===//
872
Stephen Kellycdbfb302018-12-02 17:30:40 +0000873void ASTDumper::dumpComment(const Comment *C, const FullComment *FC) {
Stephen Kellyd8aeb552019-01-30 19:41:04 +0000874 NodeDumper.AddChild([=] {
Stephen Kellye26a88a2018-12-09 13:30:17 +0000875 NodeDumper.Visit(C, FC);
Richard Smithf7514452014-10-30 21:02:37 +0000876 if (!C) {
Richard Smithf7514452014-10-30 21:02:37 +0000877 return;
878 }
Stephen Kellycdbfb302018-12-02 17:30:40 +0000879 ConstCommentVisitor<ASTDumper, void, const FullComment *>::visit(C, FC);
Richard Smithf7514452014-10-30 21:02:37 +0000880 for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
881 I != E; ++I)
Stephen Kellycdbfb302018-12-02 17:30:40 +0000882 dumpComment(*I, FC);
Richard Smithf7514452014-10-30 21:02:37 +0000883 });
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000884}
885
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000886//===----------------------------------------------------------------------===//
Richard Smithd5e7ff82014-10-31 01:17:45 +0000887// Type method implementations
888//===----------------------------------------------------------------------===//
889
890void QualType::dump(const char *msg) const {
891 if (msg)
892 llvm::errs() << msg << ": ";
893 dump();
894}
895
Richard Smith14d04842016-11-02 23:57:18 +0000896LLVM_DUMP_METHOD void QualType::dump() const { dump(llvm::errs()); }
897
898LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream &OS) const {
899 ASTDumper Dumper(OS, nullptr, nullptr);
Richard Smithd5e7ff82014-10-31 01:17:45 +0000900 Dumper.dumpTypeAsChild(*this);
901}
902
Richard Smith14d04842016-11-02 23:57:18 +0000903LLVM_DUMP_METHOD void Type::dump() const { dump(llvm::errs()); }
904
905LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS) const {
906 QualType(this, 0).dump(OS);
907}
Richard Smithd5e7ff82014-10-31 01:17:45 +0000908
909//===----------------------------------------------------------------------===//
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000910// Decl method implementations
911//===----------------------------------------------------------------------===//
912
Alp Tokeref6b0072014-01-04 13:47:14 +0000913LLVM_DUMP_METHOD void Decl::dump() const { dump(llvm::errs()); }
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000914
Richard Smith3a36ac12017-03-09 22:00:01 +0000915LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS, bool Deserialize) const {
Aaron Ballman8c208282017-12-21 21:42:42 +0000916 const ASTContext &Ctx = getASTContext();
917 const SourceManager &SM = Ctx.getSourceManager();
918 ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &SM,
919 SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
Richard Smith3a36ac12017-03-09 22:00:01 +0000920 P.setDeserialize(Deserialize);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000921 P.dumpDecl(this);
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000922}
923
Alp Tokeref6b0072014-01-04 13:47:14 +0000924LLVM_DUMP_METHOD void Decl::dumpColor() const {
Aaron Ballman8c208282017-12-21 21:42:42 +0000925 const ASTContext &Ctx = getASTContext();
926 ASTDumper P(llvm::errs(), &Ctx.getCommentCommandTraits(),
927 &Ctx.getSourceManager(), /*ShowColors*/ true,
928 Ctx.getPrintingPolicy());
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000929 P.dumpDecl(this);
Richard Trieud215b8d2013-01-26 01:31:20 +0000930}
Richard Smith33937e72013-06-22 21:49:40 +0000931
Alp Tokeref6b0072014-01-04 13:47:14 +0000932LLVM_DUMP_METHOD void DeclContext::dumpLookups() const {
Richard Smith6ea05822013-06-24 01:45:33 +0000933 dumpLookups(llvm::errs());
934}
935
Richard Smith35f986d2014-08-11 22:11:07 +0000936LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS,
Richard Smith3a36ac12017-03-09 22:00:01 +0000937 bool DumpDecls,
938 bool Deserialize) const {
Richard Smith33937e72013-06-22 21:49:40 +0000939 const DeclContext *DC = this;
940 while (!DC->isTranslationUnit())
941 DC = DC->getParent();
942 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
Aaron Ballman8c208282017-12-21 21:42:42 +0000943 const SourceManager &SM = Ctx.getSourceManager();
944 ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &Ctx.getSourceManager(),
945 SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
Richard Smith3a36ac12017-03-09 22:00:01 +0000946 P.setDeserialize(Deserialize);
Richard Smith35f986d2014-08-11 22:11:07 +0000947 P.dumpLookups(this, DumpDecls);
Richard Smith33937e72013-06-22 21:49:40 +0000948}
949
Alexander Kornienko90ff6072012-12-20 02:09:13 +0000950//===----------------------------------------------------------------------===//
Chris Lattnercbe4f772007-08-08 22:51:59 +0000951// Stmt method implementations
952//===----------------------------------------------------------------------===//
953
Alp Tokeref6b0072014-01-04 13:47:14 +0000954LLVM_DUMP_METHOD void Stmt::dump(SourceManager &SM) const {
Argyrios Kyrtzidisc049f752010-08-09 10:54:31 +0000955 dump(llvm::errs(), SM);
956}
957
Alp Tokeref6b0072014-01-04 13:47:14 +0000958LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS, SourceManager &SM) const {
Craig Topper36250ad2014-05-12 05:36:57 +0000959 ASTDumper P(OS, nullptr, &SM);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000960 P.dumpStmt(this);
Chris Lattner779d5d92007-08-30 00:40:08 +0000961}
962
Faisal Vali2da8ed92015-03-22 13:35:56 +0000963LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS) const {
964 ASTDumper P(OS, nullptr, nullptr);
965 P.dumpStmt(this);
966}
967
Alp Tokeref6b0072014-01-04 13:47:14 +0000968LLVM_DUMP_METHOD void Stmt::dump() const {
Craig Topper36250ad2014-05-12 05:36:57 +0000969 ASTDumper P(llvm::errs(), nullptr, nullptr);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000970 P.dumpStmt(this);
Chris Lattnercbe4f772007-08-08 22:51:59 +0000971}
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000972
Alp Tokeref6b0072014-01-04 13:47:14 +0000973LLVM_DUMP_METHOD void Stmt::dumpColor() const {
Craig Topper36250ad2014-05-12 05:36:57 +0000974 ASTDumper P(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
Alexander Kornienko540bacb2013-02-01 12:35:51 +0000975 P.dumpStmt(this);
Richard Trieud215b8d2013-01-26 01:31:20 +0000976}
977
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000978//===----------------------------------------------------------------------===//
979// Comment method implementations
980//===----------------------------------------------------------------------===//
981
Craig Topper36250ad2014-05-12 05:36:57 +0000982LLVM_DUMP_METHOD void Comment::dump() const {
983 dump(llvm::errs(), nullptr, nullptr);
984}
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000985
Alp Tokeref6b0072014-01-04 13:47:14 +0000986LLVM_DUMP_METHOD void Comment::dump(const ASTContext &Context) const {
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000987 dump(llvm::errs(), &Context.getCommentCommandTraits(),
988 &Context.getSourceManager());
989}
990
Alexander Kornienko00911f12013-01-15 12:20:21 +0000991void Comment::dump(raw_ostream &OS, const CommandTraits *Traits,
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000992 const SourceManager *SM) const {
993 const FullComment *FC = dyn_cast<FullComment>(this);
Stephen Kelly570b2972018-12-09 13:18:55 +0000994 if (!FC)
995 return;
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000996 ASTDumper D(OS, Traits, SM);
Stephen Kelly570b2972018-12-09 13:18:55 +0000997 D.dumpComment(FC, FC);
Alexander Kornienkoebc17b52013-01-14 14:07:11 +0000998}
Richard Trieud215b8d2013-01-26 01:31:20 +0000999
Alp Tokeref6b0072014-01-04 13:47:14 +00001000LLVM_DUMP_METHOD void Comment::dumpColor() const {
Richard Trieud215b8d2013-01-26 01:31:20 +00001001 const FullComment *FC = dyn_cast<FullComment>(this);
Stephen Kelly570b2972018-12-09 13:18:55 +00001002 if (!FC)
1003 return;
Craig Topper36250ad2014-05-12 05:36:57 +00001004 ASTDumper D(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
Stephen Kelly570b2972018-12-09 13:18:55 +00001005 D.dumpComment(FC, FC);
Richard Trieud215b8d2013-01-26 01:31:20 +00001006}