| Alexander Kornienko | 18ec81b | 2012-12-13 13:59:55 +0000 | [diff] [blame] | 1 | //===--- ASTDumper.cpp - Dumping implementation for ASTs ------------------===// |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| Alexander Kornienko | 18ec81b | 2012-12-13 13:59:55 +0000 | [diff] [blame] | 9 | // This file implements the AST dump methods, which dump out the |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 10 | // AST in a form that exposes type details and other fields. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| Stephen Kelly | c8dcbed | 2019-05-17 13:59:15 +0000 | [diff] [blame] | 14 | #include "clang/AST/ASTDumper.h" |
| Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 15 | #include "clang/AST/ASTContext.h" |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclLookups.h" |
| Aaron Ballman | 2ce598a | 2019-05-13 21:39:55 +0000 | [diff] [blame] | 17 | #include "clang/AST/JSONNodeDumper.h" |
| David Majnemer | d9b1a4f | 2015-11-04 03:40:30 +0000 | [diff] [blame] | 18 | #include "clang/Basic/Builtins.h" |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 19 | #include "clang/Basic/Module.h" |
| Chris Lattner | 11e30d3 | 2007-08-30 06:17:34 +0000 | [diff] [blame] | 20 | #include "clang/Basic/SourceManager.h" |
| Daniel Dunbar | 34a96c8 | 2009-12-03 09:13:13 +0000 | [diff] [blame] | 21 | #include "llvm/Support/raw_ostream.h" |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 22 | using namespace clang; |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 23 | using namespace clang::comments; |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 24 | |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 25 | void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) { |
| Stephen Kelly | d8aeb55 | 2019-01-30 19:41:04 +0000 | [diff] [blame] | 26 | NodeDumper.AddChild([=] { |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 27 | OS << "StoredDeclsMap "; |
| Stephen Kelly | d8744a7 | 2018-12-05 21:12:39 +0000 | [diff] [blame] | 28 | NodeDumper.dumpBareDeclRef(cast<Decl>(DC)); |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 29 | |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 30 | const DeclContext *Primary = DC->getPrimaryContext(); |
| 31 | if (Primary != DC) { |
| 32 | OS << " primary"; |
| Stephen Kelly | d8744a7 | 2018-12-05 21:12:39 +0000 | [diff] [blame] | 33 | NodeDumper.dumpPointer(cast<Decl>(Primary)); |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 36 | bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage(); |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 37 | |
| Stephen Kelly | c493301 | 2019-02-03 14:06:54 +0000 | [diff] [blame] | 38 | auto Range = getDeserialize() |
| Sam McCall | 091b1ef | 2018-01-16 12:33:46 +0000 | [diff] [blame] | 39 | ? Primary->lookups() |
| 40 | : Primary->noload_lookups(/*PreserveInternalState=*/true); |
| 41 | for (auto I = Range.begin(), E = Range.end(); I != E; ++I) { |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 42 | DeclarationName Name = I.getLookupName(); |
| Richard Smith | 3a36ac1 | 2017-03-09 22:00:01 +0000 | [diff] [blame] | 43 | DeclContextLookupResult R = *I; |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 44 | |
| Stephen Kelly | d8aeb55 | 2019-01-30 19:41:04 +0000 | [diff] [blame] | 45 | NodeDumper.AddChild([=] { |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 46 | OS << "DeclarationName "; |
| 47 | { |
| Stephen Kelly | 27e948c | 2018-11-29 19:30:37 +0000 | [diff] [blame] | 48 | ColorScope Color(OS, ShowColors, DeclNameColor); |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 49 | OS << '\'' << Name << '\''; |
| 50 | } |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 51 | |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 52 | for (DeclContextLookupResult::iterator RI = R.begin(), RE = R.end(); |
| 53 | RI != RE; ++RI) { |
| Stephen Kelly | d8aeb55 | 2019-01-30 19:41:04 +0000 | [diff] [blame] | 54 | NodeDumper.AddChild([=] { |
| Stephen Kelly | d8744a7 | 2018-12-05 21:12:39 +0000 | [diff] [blame] | 55 | NodeDumper.dumpBareDeclRef(*RI); |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 56 | |
| 57 | if ((*RI)->isHidden()) |
| 58 | OS << " hidden"; |
| 59 | |
| 60 | // If requested, dump the redecl chain for this lookup. |
| 61 | if (DumpDecls) { |
| 62 | // Dump earliest decl first. |
| 63 | std::function<void(Decl *)> DumpWithPrev = [&](Decl *D) { |
| 64 | if (Decl *Prev = D->getPreviousDecl()) |
| 65 | DumpWithPrev(Prev); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 66 | Visit(D); |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 67 | }; |
| 68 | DumpWithPrev(*RI); |
| 69 | } |
| 70 | }); |
| 71 | } |
| 72 | }); |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 73 | } |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 74 | |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 75 | if (HasUndeserializedLookups) { |
| Stephen Kelly | d8aeb55 | 2019-01-30 19:41:04 +0000 | [diff] [blame] | 76 | NodeDumper.AddChild([=] { |
| Stephen Kelly | 27e948c | 2018-11-29 19:30:37 +0000 | [diff] [blame] | 77 | ColorScope Color(OS, ShowColors, UndeserializedColor); |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 78 | OS << "<undeserialized lookups>"; |
| 79 | }); |
| 80 | } |
| 81 | }); |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 84 | template <typename SpecializationDecl> |
| 85 | void ASTDumper::dumpTemplateDeclSpecialization(const SpecializationDecl *D, |
| 86 | bool DumpExplicitInst, |
| 87 | bool DumpRefOnly) { |
| Richard Smith | cbdf733 | 2014-03-18 02:07:28 +0000 | [diff] [blame] | 88 | bool DumpedAny = false; |
| Stephen Kelly | aaebc5f | 2019-01-19 09:57:51 +0000 | [diff] [blame] | 89 | for (const auto *RedeclWithBadType : D->redecls()) { |
| Richard Smith | cbdf733 | 2014-03-18 02:07:28 +0000 | [diff] [blame] | 90 | // FIXME: The redecls() range sometimes has elements of a less-specific |
| 91 | // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives |
| 92 | // us TagDecls, and should give CXXRecordDecls). |
| 93 | auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType); |
| 94 | if (!Redecl) { |
| 95 | // Found the injected-class-name for a class template. This will be dumped |
| 96 | // as part of its surrounding class so we don't need to dump it here. |
| 97 | assert(isa<CXXRecordDecl>(RedeclWithBadType) && |
| 98 | "expected an injected-class-name"); |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | switch (Redecl->getTemplateSpecializationKind()) { |
| 103 | case TSK_ExplicitInstantiationDeclaration: |
| 104 | case TSK_ExplicitInstantiationDefinition: |
| 105 | if (!DumpExplicitInst) |
| 106 | break; |
| Adrian Prantl | f3b3ccd | 2017-12-19 22:06:11 +0000 | [diff] [blame] | 107 | LLVM_FALLTHROUGH; |
| Richard Smith | cbdf733 | 2014-03-18 02:07:28 +0000 | [diff] [blame] | 108 | case TSK_Undeclared: |
| 109 | case TSK_ImplicitInstantiation: |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 110 | if (DumpRefOnly) |
| Stephen Kelly | d186dbc | 2019-01-08 23:11:24 +0000 | [diff] [blame] | 111 | NodeDumper.dumpDeclRef(Redecl); |
| Richard Smith | f751445 | 2014-10-30 21:02:37 +0000 | [diff] [blame] | 112 | else |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 113 | Visit(Redecl); |
| Richard Smith | cbdf733 | 2014-03-18 02:07:28 +0000 | [diff] [blame] | 114 | DumpedAny = true; |
| 115 | break; |
| 116 | case TSK_ExplicitSpecialization: |
| 117 | break; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // Ensure we dump at least one decl for each specialization. |
| 122 | if (!DumpedAny) |
| Stephen Kelly | d186dbc | 2019-01-08 23:11:24 +0000 | [diff] [blame] | 123 | NodeDumper.dumpDeclRef(D); |
| Richard Smith | cbdf733 | 2014-03-18 02:07:28 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 126 | template <typename TemplateDecl> |
| 127 | void ASTDumper::dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst) { |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 128 | dumpTemplateParameters(D->getTemplateParameters()); |
| Richard Smith | dcc2c45 | 2014-03-17 23:00:06 +0000 | [diff] [blame] | 129 | |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 130 | Visit(D->getTemplatedDecl()); |
| Richard Smith | dcc2c45 | 2014-03-17 23:00:06 +0000 | [diff] [blame] | 131 | |
| Stephen Kelly | aaebc5f | 2019-01-19 09:57:51 +0000 | [diff] [blame] | 132 | for (const auto *Child : D->specializations()) |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 133 | dumpTemplateDeclSpecialization(Child, DumpExplicitInst, |
| 134 | !D->isCanonicalDecl()); |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| Richard Smith | 20ade55 | 2014-03-17 23:34:53 +0000 | [diff] [blame] | 137 | void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) { |
| 138 | // FIXME: We don't add a declaration of a function template specialization |
| 139 | // to its context when it's explicitly instantiated, so dump explicit |
| 140 | // instantiations when we dump the template itself. |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 141 | dumpTemplateDecl(D, true); |
| Richard Smith | 20ade55 | 2014-03-17 23:34:53 +0000 | [diff] [blame] | 142 | } |
| 143 | |
| Alexander Kornienko | 540bacb | 2013-02-01 12:35:51 +0000 | [diff] [blame] | 144 | void ASTDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) { |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 145 | dumpTemplateDecl(D, false); |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| Richard Smith | d25789a | 2013-09-18 01:36:02 +0000 | [diff] [blame] | 148 | void ASTDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) { |
| Stephen Kelly | 2413638 | 2018-12-09 13:33:30 +0000 | [diff] [blame] | 149 | dumpTemplateDecl(D, false); |
| Richard Smith | d25789a | 2013-09-18 01:36:02 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 152 | //===----------------------------------------------------------------------===// |
| Richard Smith | d5e7ff8 | 2014-10-31 01:17:45 +0000 | [diff] [blame] | 153 | // Type method implementations |
| 154 | //===----------------------------------------------------------------------===// |
| 155 | |
| 156 | void QualType::dump(const char *msg) const { |
| 157 | if (msg) |
| 158 | llvm::errs() << msg << ": "; |
| 159 | dump(); |
| 160 | } |
| 161 | |
| Richard Smith | 14d0484 | 2016-11-02 23:57:18 +0000 | [diff] [blame] | 162 | LLVM_DUMP_METHOD void QualType::dump() const { dump(llvm::errs()); } |
| 163 | |
| 164 | LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream &OS) const { |
| 165 | ASTDumper Dumper(OS, nullptr, nullptr); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 166 | Dumper.Visit(*this); |
| Richard Smith | d5e7ff8 | 2014-10-31 01:17:45 +0000 | [diff] [blame] | 167 | } |
| 168 | |
| Richard Smith | 14d0484 | 2016-11-02 23:57:18 +0000 | [diff] [blame] | 169 | LLVM_DUMP_METHOD void Type::dump() const { dump(llvm::errs()); } |
| 170 | |
| 171 | LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS) const { |
| 172 | QualType(this, 0).dump(OS); |
| 173 | } |
| Richard Smith | d5e7ff8 | 2014-10-31 01:17:45 +0000 | [diff] [blame] | 174 | |
| 175 | //===----------------------------------------------------------------------===// |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 176 | // Decl method implementations |
| 177 | //===----------------------------------------------------------------------===// |
| 178 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 179 | LLVM_DUMP_METHOD void Decl::dump() const { dump(llvm::errs()); } |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 180 | |
| Aaron Ballman | 2ce598a | 2019-05-13 21:39:55 +0000 | [diff] [blame] | 181 | LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS, bool Deserialize, |
| 182 | ASTDumpOutputFormat Format) const { |
| Aaron Ballman | e091ab1 | 2019-05-27 14:34:31 +0000 | [diff] [blame] | 183 | ASTContext &Ctx = getASTContext(); |
| Aaron Ballman | 8c20828 | 2017-12-21 21:42:42 +0000 | [diff] [blame] | 184 | const SourceManager &SM = Ctx.getSourceManager(); |
| Aaron Ballman | 2ce598a | 2019-05-13 21:39:55 +0000 | [diff] [blame] | 185 | |
| 186 | if (ADOF_JSON == Format) { |
| Aaron Ballman | e091ab1 | 2019-05-27 14:34:31 +0000 | [diff] [blame] | 187 | JSONDumper P(OS, SM, Ctx, Ctx.getPrintingPolicy(), |
| Aaron Ballman | 86abee8 | 2019-05-21 14:38:29 +0000 | [diff] [blame] | 188 | &Ctx.getCommentCommandTraits()); |
| Aaron Ballman | 2ce598a | 2019-05-13 21:39:55 +0000 | [diff] [blame] | 189 | (void)Deserialize; // FIXME? |
| 190 | P.Visit(this); |
| 191 | } else { |
| 192 | ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &SM, |
| 193 | SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy()); |
| 194 | P.setDeserialize(Deserialize); |
| 195 | P.Visit(this); |
| 196 | } |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 199 | LLVM_DUMP_METHOD void Decl::dumpColor() const { |
| Aaron Ballman | 8c20828 | 2017-12-21 21:42:42 +0000 | [diff] [blame] | 200 | const ASTContext &Ctx = getASTContext(); |
| 201 | ASTDumper P(llvm::errs(), &Ctx.getCommentCommandTraits(), |
| 202 | &Ctx.getSourceManager(), /*ShowColors*/ true, |
| 203 | Ctx.getPrintingPolicy()); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 204 | P.Visit(this); |
| Richard Trieu | d215b8d | 2013-01-26 01:31:20 +0000 | [diff] [blame] | 205 | } |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 206 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 207 | LLVM_DUMP_METHOD void DeclContext::dumpLookups() const { |
| Richard Smith | 6ea0582 | 2013-06-24 01:45:33 +0000 | [diff] [blame] | 208 | dumpLookups(llvm::errs()); |
| 209 | } |
| 210 | |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 211 | LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS, |
| Richard Smith | 3a36ac1 | 2017-03-09 22:00:01 +0000 | [diff] [blame] | 212 | bool DumpDecls, |
| 213 | bool Deserialize) const { |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 214 | const DeclContext *DC = this; |
| 215 | while (!DC->isTranslationUnit()) |
| 216 | DC = DC->getParent(); |
| 217 | ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext(); |
| Aaron Ballman | 8c20828 | 2017-12-21 21:42:42 +0000 | [diff] [blame] | 218 | const SourceManager &SM = Ctx.getSourceManager(); |
| 219 | ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &Ctx.getSourceManager(), |
| 220 | SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy()); |
| Richard Smith | 3a36ac1 | 2017-03-09 22:00:01 +0000 | [diff] [blame] | 221 | P.setDeserialize(Deserialize); |
| Richard Smith | 35f986d | 2014-08-11 22:11:07 +0000 | [diff] [blame] | 222 | P.dumpLookups(this, DumpDecls); |
| Richard Smith | 33937e7 | 2013-06-22 21:49:40 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| Alexander Kornienko | 90ff607 | 2012-12-20 02:09:13 +0000 | [diff] [blame] | 225 | //===----------------------------------------------------------------------===// |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 226 | // Stmt method implementations |
| 227 | //===----------------------------------------------------------------------===// |
| 228 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 229 | LLVM_DUMP_METHOD void Stmt::dump(SourceManager &SM) const { |
| Argyrios Kyrtzidis | c049f75 | 2010-08-09 10:54:31 +0000 | [diff] [blame] | 230 | dump(llvm::errs(), SM); |
| 231 | } |
| 232 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 233 | LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS, SourceManager &SM) const { |
| Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 234 | ASTDumper P(OS, nullptr, &SM); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 235 | P.Visit(this); |
| Chris Lattner | 779d5d9 | 2007-08-30 00:40:08 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| Faisal Vali | 2da8ed9 | 2015-03-22 13:35:56 +0000 | [diff] [blame] | 238 | LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS) const { |
| 239 | ASTDumper P(OS, nullptr, nullptr); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 240 | P.Visit(this); |
| Faisal Vali | 2da8ed9 | 2015-03-22 13:35:56 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 243 | LLVM_DUMP_METHOD void Stmt::dump() const { |
| Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 244 | ASTDumper P(llvm::errs(), nullptr, nullptr); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 245 | P.Visit(this); |
| Chris Lattner | cbe4f77 | 2007-08-08 22:51:59 +0000 | [diff] [blame] | 246 | } |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 247 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 248 | LLVM_DUMP_METHOD void Stmt::dumpColor() const { |
| Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 249 | ASTDumper P(llvm::errs(), nullptr, nullptr, /*ShowColors*/true); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 250 | P.Visit(this); |
| Richard Trieu | d215b8d | 2013-01-26 01:31:20 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 253 | //===----------------------------------------------------------------------===// |
| 254 | // Comment method implementations |
| 255 | //===----------------------------------------------------------------------===// |
| 256 | |
| Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 257 | LLVM_DUMP_METHOD void Comment::dump() const { |
| 258 | dump(llvm::errs(), nullptr, nullptr); |
| 259 | } |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 260 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 261 | LLVM_DUMP_METHOD void Comment::dump(const ASTContext &Context) const { |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 262 | dump(llvm::errs(), &Context.getCommentCommandTraits(), |
| 263 | &Context.getSourceManager()); |
| 264 | } |
| 265 | |
| Alexander Kornienko | 00911f1 | 2013-01-15 12:20:21 +0000 | [diff] [blame] | 266 | void Comment::dump(raw_ostream &OS, const CommandTraits *Traits, |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 267 | const SourceManager *SM) const { |
| 268 | const FullComment *FC = dyn_cast<FullComment>(this); |
| Stephen Kelly | 570b297 | 2018-12-09 13:18:55 +0000 | [diff] [blame] | 269 | if (!FC) |
| 270 | return; |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 271 | ASTDumper D(OS, Traits, SM); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 272 | D.Visit(FC, FC); |
| Alexander Kornienko | ebc17b5 | 2013-01-14 14:07:11 +0000 | [diff] [blame] | 273 | } |
| Richard Trieu | d215b8d | 2013-01-26 01:31:20 +0000 | [diff] [blame] | 274 | |
| Alp Toker | ef6b007 | 2014-01-04 13:47:14 +0000 | [diff] [blame] | 275 | LLVM_DUMP_METHOD void Comment::dumpColor() const { |
| Richard Trieu | d215b8d | 2013-01-26 01:31:20 +0000 | [diff] [blame] | 276 | const FullComment *FC = dyn_cast<FullComment>(this); |
| Stephen Kelly | 570b297 | 2018-12-09 13:18:55 +0000 | [diff] [blame] | 277 | if (!FC) |
| 278 | return; |
| Craig Topper | 36250ad | 2014-05-12 05:36:57 +0000 | [diff] [blame] | 279 | ASTDumper D(llvm::errs(), nullptr, nullptr, /*ShowColors*/true); |
| Stephen Kelly | 6d110d6 | 2019-01-30 19:49:49 +0000 | [diff] [blame] | 280 | D.Visit(FC, FC); |
| Richard Trieu | d215b8d | 2013-01-26 01:31:20 +0000 | [diff] [blame] | 281 | } |