xref: /freebsd-src/contrib/llvm-project/clang/lib/AST/ASTDumper.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===--- ASTDumper.cpp - Dumping implementation for ASTs ------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file implements the AST dump methods, which dump out the
100b57cec5SDimitry Andric // AST in a form that exposes type details and other fields.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #include "clang/AST/ASTDumper.h"
155f757f3fSDimitry Andric #include "clang/AST/ASTConcept.h"
160b57cec5SDimitry Andric #include "clang/AST/ASTContext.h"
170b57cec5SDimitry Andric #include "clang/AST/DeclLookups.h"
180b57cec5SDimitry Andric #include "clang/AST/JSONNodeDumper.h"
190b57cec5SDimitry Andric #include "clang/Basic/Builtins.h"
200b57cec5SDimitry Andric #include "clang/Basic/SourceManager.h"
210b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h"
22bdd1243dSDimitry Andric 
230b57cec5SDimitry Andric using namespace clang;
240b57cec5SDimitry Andric using namespace clang::comments;
250b57cec5SDimitry Andric 
26bdd1243dSDimitry Andric void ASTDumper::dumpInvalidDeclContext(const DeclContext *DC) {
27bdd1243dSDimitry Andric   NodeDumper.AddChild([=] {
28bdd1243dSDimitry Andric     if (!DC) {
29bdd1243dSDimitry Andric       ColorScope Color(OS, ShowColors, NullColor);
30bdd1243dSDimitry Andric       OS << "<<<NULL>>>";
31bdd1243dSDimitry Andric       return;
32bdd1243dSDimitry Andric     }
33bdd1243dSDimitry Andric     // An invalid DeclContext is one for which a dyn_cast() from a DeclContext
34bdd1243dSDimitry Andric     // pointer to a Decl pointer would fail an assertion or otherwise fall prey
35bdd1243dSDimitry Andric     // to undefined behavior as a result of an invalid associated DeclKind.
36bdd1243dSDimitry Andric     // Such invalidity is not supposed to happen of course, but, when it does,
37bdd1243dSDimitry Andric     // the information provided below is intended to provide some hints about
38bdd1243dSDimitry Andric     // what might have gone awry.
39bdd1243dSDimitry Andric     {
40bdd1243dSDimitry Andric       ColorScope Color(OS, ShowColors, DeclKindNameColor);
41bdd1243dSDimitry Andric       OS << "DeclContext";
42bdd1243dSDimitry Andric     }
43bdd1243dSDimitry Andric     NodeDumper.dumpPointer(DC);
44bdd1243dSDimitry Andric     OS << " <";
45bdd1243dSDimitry Andric     {
46bdd1243dSDimitry Andric       ColorScope Color(OS, ShowColors, DeclNameColor);
47bdd1243dSDimitry Andric       OS << "unrecognized Decl kind " << (unsigned)DC->getDeclKind();
48bdd1243dSDimitry Andric     }
49bdd1243dSDimitry Andric     OS << ">";
50bdd1243dSDimitry Andric   });
51bdd1243dSDimitry Andric }
52bdd1243dSDimitry Andric 
530b57cec5SDimitry Andric void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
540b57cec5SDimitry Andric   NodeDumper.AddChild([=] {
550b57cec5SDimitry Andric     OS << "StoredDeclsMap ";
560b57cec5SDimitry Andric     NodeDumper.dumpBareDeclRef(cast<Decl>(DC));
570b57cec5SDimitry Andric 
580b57cec5SDimitry Andric     const DeclContext *Primary = DC->getPrimaryContext();
590b57cec5SDimitry Andric     if (Primary != DC) {
600b57cec5SDimitry Andric       OS << " primary";
610b57cec5SDimitry Andric       NodeDumper.dumpPointer(cast<Decl>(Primary));
620b57cec5SDimitry Andric     }
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric     bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric     auto Range = getDeserialize()
670b57cec5SDimitry Andric                      ? Primary->lookups()
680b57cec5SDimitry Andric                      : Primary->noload_lookups(/*PreserveInternalState=*/true);
690b57cec5SDimitry Andric     for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {
700b57cec5SDimitry Andric       DeclarationName Name = I.getLookupName();
710b57cec5SDimitry Andric       DeclContextLookupResult R = *I;
720b57cec5SDimitry Andric 
730b57cec5SDimitry Andric       NodeDumper.AddChild([=] {
740b57cec5SDimitry Andric         OS << "DeclarationName ";
750b57cec5SDimitry Andric         {
760b57cec5SDimitry Andric           ColorScope Color(OS, ShowColors, DeclNameColor);
770b57cec5SDimitry Andric           OS << '\'' << Name << '\'';
780b57cec5SDimitry Andric         }
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric         for (DeclContextLookupResult::iterator RI = R.begin(), RE = R.end();
810b57cec5SDimitry Andric              RI != RE; ++RI) {
820b57cec5SDimitry Andric           NodeDumper.AddChild([=] {
830b57cec5SDimitry Andric             NodeDumper.dumpBareDeclRef(*RI);
840b57cec5SDimitry Andric 
855ffd83dbSDimitry Andric             if (!(*RI)->isUnconditionallyVisible())
860b57cec5SDimitry Andric               OS << " hidden";
870b57cec5SDimitry Andric 
880b57cec5SDimitry Andric             // If requested, dump the redecl chain for this lookup.
890b57cec5SDimitry Andric             if (DumpDecls) {
900b57cec5SDimitry Andric               // Dump earliest decl first.
910b57cec5SDimitry Andric               std::function<void(Decl *)> DumpWithPrev = [&](Decl *D) {
920b57cec5SDimitry Andric                 if (Decl *Prev = D->getPreviousDecl())
930b57cec5SDimitry Andric                   DumpWithPrev(Prev);
940b57cec5SDimitry Andric                 Visit(D);
950b57cec5SDimitry Andric               };
960b57cec5SDimitry Andric               DumpWithPrev(*RI);
970b57cec5SDimitry Andric             }
980b57cec5SDimitry Andric           });
990b57cec5SDimitry Andric         }
1000b57cec5SDimitry Andric       });
1010b57cec5SDimitry Andric     }
1020b57cec5SDimitry Andric 
1030b57cec5SDimitry Andric     if (HasUndeserializedLookups) {
1040b57cec5SDimitry Andric       NodeDumper.AddChild([=] {
1050b57cec5SDimitry Andric         ColorScope Color(OS, ShowColors, UndeserializedColor);
1060b57cec5SDimitry Andric         OS << "<undeserialized lookups>";
1070b57cec5SDimitry Andric       });
1080b57cec5SDimitry Andric     }
1090b57cec5SDimitry Andric   });
1100b57cec5SDimitry Andric }
1110b57cec5SDimitry Andric 
1120b57cec5SDimitry Andric template <typename SpecializationDecl>
1130b57cec5SDimitry Andric void ASTDumper::dumpTemplateDeclSpecialization(const SpecializationDecl *D,
1140b57cec5SDimitry Andric                                                bool DumpExplicitInst,
1150b57cec5SDimitry Andric                                                bool DumpRefOnly) {
1160b57cec5SDimitry Andric   bool DumpedAny = false;
1170b57cec5SDimitry Andric   for (const auto *RedeclWithBadType : D->redecls()) {
1180b57cec5SDimitry Andric     // FIXME: The redecls() range sometimes has elements of a less-specific
1190b57cec5SDimitry Andric     // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
1200b57cec5SDimitry Andric     // us TagDecls, and should give CXXRecordDecls).
121349cc55cSDimitry Andric     auto *Redecl = cast<SpecializationDecl>(RedeclWithBadType);
1220b57cec5SDimitry Andric     switch (Redecl->getTemplateSpecializationKind()) {
1230b57cec5SDimitry Andric     case TSK_ExplicitInstantiationDeclaration:
1240b57cec5SDimitry Andric     case TSK_ExplicitInstantiationDefinition:
1250b57cec5SDimitry Andric       if (!DumpExplicitInst)
1260b57cec5SDimitry Andric         break;
127bdd1243dSDimitry Andric       [[fallthrough]];
1280b57cec5SDimitry Andric     case TSK_Undeclared:
1290b57cec5SDimitry Andric     case TSK_ImplicitInstantiation:
1300b57cec5SDimitry Andric       if (DumpRefOnly)
1310b57cec5SDimitry Andric         NodeDumper.dumpDeclRef(Redecl);
1320b57cec5SDimitry Andric       else
1330b57cec5SDimitry Andric         Visit(Redecl);
1340b57cec5SDimitry Andric       DumpedAny = true;
1350b57cec5SDimitry Andric       break;
1360b57cec5SDimitry Andric     case TSK_ExplicitSpecialization:
1370b57cec5SDimitry Andric       break;
1380b57cec5SDimitry Andric     }
1390b57cec5SDimitry Andric   }
1400b57cec5SDimitry Andric 
1410b57cec5SDimitry Andric   // Ensure we dump at least one decl for each specialization.
1420b57cec5SDimitry Andric   if (!DumpedAny)
1430b57cec5SDimitry Andric     NodeDumper.dumpDeclRef(D);
1440b57cec5SDimitry Andric }
1450b57cec5SDimitry Andric 
1460b57cec5SDimitry Andric template <typename TemplateDecl>
1470b57cec5SDimitry Andric void ASTDumper::dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst) {
1480b57cec5SDimitry Andric   dumpTemplateParameters(D->getTemplateParameters());
1490b57cec5SDimitry Andric 
1500b57cec5SDimitry Andric   Visit(D->getTemplatedDecl());
1510b57cec5SDimitry Andric 
152e8d8bef9SDimitry Andric   if (GetTraversalKind() == TK_AsIs) {
1530b57cec5SDimitry Andric     for (const auto *Child : D->specializations())
1540b57cec5SDimitry Andric       dumpTemplateDeclSpecialization(Child, DumpExplicitInst,
1550b57cec5SDimitry Andric                                      !D->isCanonicalDecl());
1560b57cec5SDimitry Andric   }
157e8d8bef9SDimitry Andric }
1580b57cec5SDimitry Andric 
1590b57cec5SDimitry Andric void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
1600b57cec5SDimitry Andric   // FIXME: We don't add a declaration of a function template specialization
1610b57cec5SDimitry Andric   // to its context when it's explicitly instantiated, so dump explicit
1620b57cec5SDimitry Andric   // instantiations when we dump the template itself.
1630b57cec5SDimitry Andric   dumpTemplateDecl(D, true);
1640b57cec5SDimitry Andric }
1650b57cec5SDimitry Andric 
1660b57cec5SDimitry Andric void ASTDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
1670b57cec5SDimitry Andric   dumpTemplateDecl(D, false);
1680b57cec5SDimitry Andric }
1690b57cec5SDimitry Andric 
1700b57cec5SDimitry Andric void ASTDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) {
1710b57cec5SDimitry Andric   dumpTemplateDecl(D, false);
1720b57cec5SDimitry Andric }
1730b57cec5SDimitry Andric 
1740b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
1750b57cec5SDimitry Andric // Type method implementations
1760b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
1770b57cec5SDimitry Andric 
1780b57cec5SDimitry Andric void QualType::dump(const char *msg) const {
1790b57cec5SDimitry Andric   if (msg)
1800b57cec5SDimitry Andric     llvm::errs() << msg << ": ";
1810b57cec5SDimitry Andric   dump();
1820b57cec5SDimitry Andric }
1830b57cec5SDimitry Andric 
1845ffd83dbSDimitry Andric LLVM_DUMP_METHOD void QualType::dump() const {
1855ffd83dbSDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false);
1860b57cec5SDimitry Andric   Dumper.Visit(*this);
1870b57cec5SDimitry Andric }
1880b57cec5SDimitry Andric 
1895ffd83dbSDimitry Andric LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream &OS,
1905ffd83dbSDimitry Andric                                      const ASTContext &Context) const {
1915ffd83dbSDimitry Andric   ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());
1925ffd83dbSDimitry Andric   Dumper.Visit(*this);
1935ffd83dbSDimitry Andric }
1940b57cec5SDimitry Andric 
1955ffd83dbSDimitry Andric LLVM_DUMP_METHOD void Type::dump() const { QualType(this, 0).dump(); }
1965ffd83dbSDimitry Andric 
1975ffd83dbSDimitry Andric LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS,
1985ffd83dbSDimitry Andric                                  const ASTContext &Context) const {
1995ffd83dbSDimitry Andric   QualType(this, 0).dump(OS, Context);
2000b57cec5SDimitry Andric }
2010b57cec5SDimitry Andric 
2020b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
203*0fca6ea1SDimitry Andric // TypeLoc method implementations
204*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
205*0fca6ea1SDimitry Andric 
206*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TypeLoc::dump() const {
207*0fca6ea1SDimitry Andric   ASTDumper(llvm::errs(), /*ShowColors=*/false).Visit(*this);
208*0fca6ea1SDimitry Andric }
209*0fca6ea1SDimitry Andric 
210*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TypeLoc::dump(llvm::raw_ostream &OS,
211*0fca6ea1SDimitry Andric                                     const ASTContext &Context) const {
212*0fca6ea1SDimitry Andric   ASTDumper(OS, Context, Context.getDiagnostics().getShowColors()).Visit(*this);
213*0fca6ea1SDimitry Andric }
214*0fca6ea1SDimitry Andric 
215*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
2160b57cec5SDimitry Andric // Decl method implementations
2170b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
2180b57cec5SDimitry Andric 
2190b57cec5SDimitry Andric LLVM_DUMP_METHOD void Decl::dump() const { dump(llvm::errs()); }
2200b57cec5SDimitry Andric 
2210b57cec5SDimitry Andric LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS, bool Deserialize,
2220b57cec5SDimitry Andric                                  ASTDumpOutputFormat Format) const {
2230b57cec5SDimitry Andric   ASTContext &Ctx = getASTContext();
2240b57cec5SDimitry Andric   const SourceManager &SM = Ctx.getSourceManager();
2250b57cec5SDimitry Andric 
2260b57cec5SDimitry Andric   if (ADOF_JSON == Format) {
2270b57cec5SDimitry Andric     JSONDumper P(OS, SM, Ctx, Ctx.getPrintingPolicy(),
2280b57cec5SDimitry Andric                  &Ctx.getCommentCommandTraits());
2290b57cec5SDimitry Andric     (void)Deserialize; // FIXME?
2300b57cec5SDimitry Andric     P.Visit(this);
2310b57cec5SDimitry Andric   } else {
2325ffd83dbSDimitry Andric     ASTDumper P(OS, Ctx, Ctx.getDiagnostics().getShowColors());
2330b57cec5SDimitry Andric     P.setDeserialize(Deserialize);
2340b57cec5SDimitry Andric     P.Visit(this);
2350b57cec5SDimitry Andric   }
2360b57cec5SDimitry Andric }
2370b57cec5SDimitry Andric 
2380b57cec5SDimitry Andric LLVM_DUMP_METHOD void Decl::dumpColor() const {
2390b57cec5SDimitry Andric   const ASTContext &Ctx = getASTContext();
2405ffd83dbSDimitry Andric   ASTDumper P(llvm::errs(), Ctx, /*ShowColors=*/true);
2410b57cec5SDimitry Andric   P.Visit(this);
2420b57cec5SDimitry Andric }
2430b57cec5SDimitry Andric 
244bdd1243dSDimitry Andric LLVM_DUMP_METHOD void DeclContext::dumpAsDecl() const {
245bdd1243dSDimitry Andric   dumpAsDecl(nullptr);
246bdd1243dSDimitry Andric }
247bdd1243dSDimitry Andric 
248bdd1243dSDimitry Andric LLVM_DUMP_METHOD void DeclContext::dumpAsDecl(const ASTContext *Ctx) const {
249bdd1243dSDimitry Andric   // By design, DeclContext is required to be a base class of some class that
250bdd1243dSDimitry Andric   // derives from Decl. Thus, it should always be possible to dyn_cast() from
251bdd1243dSDimitry Andric   // a DeclContext pointer to a Decl pointer and Decl::castFromDeclContext()
252bdd1243dSDimitry Andric   // asserts that to be the case. Since this function is intended for use in a
253bdd1243dSDimitry Andric   // debugger, it performs an additional check in order to prevent a failed
254bdd1243dSDimitry Andric   // cast and assertion. If that check fails, then the (invalid) DeclContext
255bdd1243dSDimitry Andric   // is dumped with an indication of its invalidity.
256bdd1243dSDimitry Andric   if (hasValidDeclKind()) {
257bdd1243dSDimitry Andric     const auto *D = cast<Decl>(this);
258bdd1243dSDimitry Andric     D->dump();
259bdd1243dSDimitry Andric   } else {
260bdd1243dSDimitry Andric     // If an ASTContext is not available, a less capable ASTDumper is
261bdd1243dSDimitry Andric     // constructed for which color diagnostics are, regrettably, disabled.
262bdd1243dSDimitry Andric     ASTDumper P = Ctx ? ASTDumper(llvm::errs(), *Ctx,
263bdd1243dSDimitry Andric                                   Ctx->getDiagnostics().getShowColors())
264bdd1243dSDimitry Andric                       : ASTDumper(llvm::errs(), /*ShowColors*/ false);
265bdd1243dSDimitry Andric     P.dumpInvalidDeclContext(this);
266bdd1243dSDimitry Andric   }
267bdd1243dSDimitry Andric }
268bdd1243dSDimitry Andric 
2690b57cec5SDimitry Andric LLVM_DUMP_METHOD void DeclContext::dumpLookups() const {
2700b57cec5SDimitry Andric   dumpLookups(llvm::errs());
2710b57cec5SDimitry Andric }
2720b57cec5SDimitry Andric 
2730b57cec5SDimitry Andric LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS,
2740b57cec5SDimitry Andric                                                bool DumpDecls,
2750b57cec5SDimitry Andric                                                bool Deserialize) const {
2760b57cec5SDimitry Andric   const DeclContext *DC = this;
2770b57cec5SDimitry Andric   while (!DC->isTranslationUnit())
2780b57cec5SDimitry Andric     DC = DC->getParent();
2795ffd83dbSDimitry Andric   const ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
2805ffd83dbSDimitry Andric   ASTDumper P(OS, Ctx, Ctx.getDiagnostics().getShowColors());
2810b57cec5SDimitry Andric   P.setDeserialize(Deserialize);
2820b57cec5SDimitry Andric   P.dumpLookups(this, DumpDecls);
2830b57cec5SDimitry Andric }
2840b57cec5SDimitry Andric 
2850b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
2860b57cec5SDimitry Andric // Stmt method implementations
2870b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
2880b57cec5SDimitry Andric 
2890b57cec5SDimitry Andric LLVM_DUMP_METHOD void Stmt::dump() const {
2905ffd83dbSDimitry Andric   ASTDumper P(llvm::errs(), /*ShowColors=*/false);
2915ffd83dbSDimitry Andric   P.Visit(this);
2925ffd83dbSDimitry Andric }
2935ffd83dbSDimitry Andric 
2945ffd83dbSDimitry Andric LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS,
2955ffd83dbSDimitry Andric                                  const ASTContext &Context) const {
2965ffd83dbSDimitry Andric   ASTDumper P(OS, Context, Context.getDiagnostics().getShowColors());
2970b57cec5SDimitry Andric   P.Visit(this);
2980b57cec5SDimitry Andric }
2990b57cec5SDimitry Andric 
3000b57cec5SDimitry Andric LLVM_DUMP_METHOD void Stmt::dumpColor() const {
3015ffd83dbSDimitry Andric   ASTDumper P(llvm::errs(), /*ShowColors=*/true);
3020b57cec5SDimitry Andric   P.Visit(this);
3030b57cec5SDimitry Andric }
3040b57cec5SDimitry Andric 
3050b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
3060b57cec5SDimitry Andric // Comment method implementations
3070b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
3080b57cec5SDimitry Andric 
3090b57cec5SDimitry Andric LLVM_DUMP_METHOD void Comment::dump() const {
3105ffd83dbSDimitry Andric   const auto *FC = dyn_cast<FullComment>(this);
3110b57cec5SDimitry Andric   if (!FC)
3120b57cec5SDimitry Andric     return;
3135ffd83dbSDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false);
3145ffd83dbSDimitry Andric   Dumper.Visit(FC, FC);
3155ffd83dbSDimitry Andric }
3165ffd83dbSDimitry Andric 
3175ffd83dbSDimitry Andric LLVM_DUMP_METHOD void Comment::dump(raw_ostream &OS,
3185ffd83dbSDimitry Andric                                     const ASTContext &Context) const {
3195ffd83dbSDimitry Andric   const auto *FC = dyn_cast<FullComment>(this);
3205ffd83dbSDimitry Andric   if (!FC)
3215ffd83dbSDimitry Andric     return;
3225ffd83dbSDimitry Andric   ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());
3235ffd83dbSDimitry Andric   Dumper.Visit(FC, FC);
3240b57cec5SDimitry Andric }
3250b57cec5SDimitry Andric 
3260b57cec5SDimitry Andric LLVM_DUMP_METHOD void Comment::dumpColor() const {
3275ffd83dbSDimitry Andric   const auto *FC = dyn_cast<FullComment>(this);
3280b57cec5SDimitry Andric   if (!FC)
3290b57cec5SDimitry Andric     return;
3305ffd83dbSDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/true);
3315ffd83dbSDimitry Andric   Dumper.Visit(FC, FC);
3325ffd83dbSDimitry Andric }
3335ffd83dbSDimitry Andric 
3345ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
3355ffd83dbSDimitry Andric // APValue method implementations
3365ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
3375ffd83dbSDimitry Andric 
3385ffd83dbSDimitry Andric LLVM_DUMP_METHOD void APValue::dump() const {
3395ffd83dbSDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false);
3405ffd83dbSDimitry Andric   Dumper.Visit(*this, /*Ty=*/QualType());
3415ffd83dbSDimitry Andric }
3425ffd83dbSDimitry Andric 
3435ffd83dbSDimitry Andric LLVM_DUMP_METHOD void APValue::dump(raw_ostream &OS,
3445ffd83dbSDimitry Andric                                     const ASTContext &Context) const {
345*0fca6ea1SDimitry Andric   ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());
3465ffd83dbSDimitry Andric   Dumper.Visit(*this, /*Ty=*/Context.getPointerType(Context.CharTy));
3470b57cec5SDimitry Andric }
3485f757f3fSDimitry Andric 
3495f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
3505f757f3fSDimitry Andric // ConceptReference method implementations
3515f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
3525f757f3fSDimitry Andric 
3535f757f3fSDimitry Andric LLVM_DUMP_METHOD void ConceptReference::dump() const {
3545f757f3fSDimitry Andric   dump(llvm::errs());
3555f757f3fSDimitry Andric }
3565f757f3fSDimitry Andric 
3575f757f3fSDimitry Andric LLVM_DUMP_METHOD void ConceptReference::dump(raw_ostream &OS) const {
3585f757f3fSDimitry Andric   auto &Ctx = getNamedConcept()->getASTContext();
3595f757f3fSDimitry Andric   ASTDumper P(OS, Ctx, Ctx.getDiagnostics().getShowColors());
3605f757f3fSDimitry Andric   P.Visit(this);
3615f757f3fSDimitry Andric }
362*0fca6ea1SDimitry Andric 
363*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
364*0fca6ea1SDimitry Andric // TemplateName method implementations
365*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
366*0fca6ea1SDimitry Andric 
367*0fca6ea1SDimitry Andric // FIXME: These are actually using the TemplateArgument dumper, through
368*0fca6ea1SDimitry Andric // an implicit conversion. The dump will claim this is a template argument,
369*0fca6ea1SDimitry Andric // which is misleading.
370*0fca6ea1SDimitry Andric 
371*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TemplateName::dump() const {
372*0fca6ea1SDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false);
373*0fca6ea1SDimitry Andric   Dumper.Visit(*this);
374*0fca6ea1SDimitry Andric }
375*0fca6ea1SDimitry Andric 
376*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TemplateName::dump(llvm::raw_ostream &OS,
377*0fca6ea1SDimitry Andric                                          const ASTContext &Context) const {
378*0fca6ea1SDimitry Andric   ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());
379*0fca6ea1SDimitry Andric   Dumper.Visit(*this);
380*0fca6ea1SDimitry Andric }
381*0fca6ea1SDimitry Andric 
382*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
383*0fca6ea1SDimitry Andric // TemplateArgument method implementations
384*0fca6ea1SDimitry Andric //===----------------------------------------------------------------------===//
385*0fca6ea1SDimitry Andric 
386*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TemplateArgument::dump() const {
387*0fca6ea1SDimitry Andric   ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false);
388*0fca6ea1SDimitry Andric   Dumper.Visit(*this);
389*0fca6ea1SDimitry Andric }
390*0fca6ea1SDimitry Andric 
391*0fca6ea1SDimitry Andric LLVM_DUMP_METHOD void TemplateArgument::dump(llvm::raw_ostream &OS,
392*0fca6ea1SDimitry Andric                                              const ASTContext &Context) const {
393*0fca6ea1SDimitry Andric   ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());
394*0fca6ea1SDimitry Andric   Dumper.Visit(*this);
395*0fca6ea1SDimitry Andric }
396