clang: lib/AST/ASTDumper.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

20#include "llvm/Support/raw_ostream.h"

21

22using namespace clang;

24

26 NodeDumper.AddChild([=] {

27 if (!DC) {

29 OS << "<<>>";

30 return;

31 }

32

33

34

35

36

37

38 {

40 OS << "DeclContext";

41 }

42 NodeDumper.dumpPointer(DC);

43 OS << " <";

44 {

47 }

48 OS << ">";

49 });

50}

51

53 NodeDumper.AddChild([=] {

54 OS << "StoredDeclsMap ";

55 NodeDumper.dumpBareDeclRef(cast(DC));

56

58 if (Primary != DC) {

59 OS << " primary";

60 NodeDumper.dumpPointer(cast(Primary));

61 }

62

64

67 : Primary->noload_lookups(true);

68 for (auto I = Range.begin(), E = Range.end(); I != E; ++I) {

71

72 NodeDumper.AddChild([=] {

73 OS << "DeclarationName ";

74 {

76 OS << '\'' << Name << '\'';

77 }

78

80 RI != RE; ++RI) {

81 NodeDumper.AddChild([=] {

82 NodeDumper.dumpBareDeclRef(*RI);

83

84 if (!(*RI)->isUnconditionallyVisible())

85 OS << " hidden";

86

87

88 if (DumpDecls) {

89

92 DumpWithPrev(Prev);

94 };

95 DumpWithPrev(*RI);

96 }

97 });

98 }

99 });

100 }

101

102 if (HasUndeserializedLookups) {

103 NodeDumper.AddChild([=] {

105 OS << "";

106 });

107 }

108 });

109}

110

111template

113 bool DumpExplicitInst,

114 bool DumpRefOnly) {

115 bool DumpedAny = false;

116 for (const auto *RedeclWithBadType : D->redecls()) {

117

118

119

120 auto *Redecl = dyn_cast(RedeclWithBadType);

121 if (!Redecl)

122 continue;

123 switch (Redecl->getTemplateSpecializationKind()) {

126 if (!DumpExplicitInst)

127 break;

128 [[fallthrough]];

131 if (DumpRefOnly)

132 NodeDumper.dumpDeclRef(Redecl);

133 else

135 DumpedAny = true;

136 break;

138 break;

139 }

140 }

141

142

143 if (!DumpedAny)

144 NodeDumper.dumpDeclRef(D);

145}

146

147template

150

152

154 for (const auto *Child : D->specializations())

157 }

158}

159

166

170

174

175

176

177

178

180 if (msg)

181 llvm::errs() << msg << ": ";

183}

184

186 ASTDumper Dumper(llvm::errs(), false);

187 Dumper.Visit(*this);

188}

189

192 ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());

193 Dumper.Visit(*this);

194}

195

197

202

203

204

205

206

210

213 ASTDumper(OS, Context, Context.getDiagnostics().getShowColors()).Visit(*this);

214}

215

216

217

218

219

221

222LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS, bool Deserialize,

226

230 (void)Deserialize;

232 } else {

236 }

237}

238

241 ASTDumper P(llvm::errs(), Ctx, true);

243}

244

248

250

251

252

253

254

255

256

259 D->dump();

260 } else {

261

262

265 : ASTDumper(llvm::errs(), false);

267 }

268}

269

273

275 bool DumpDecls,

276 bool Deserialize) const {

282 P.setDeserialize(Deserialize);

283 P.dumpLookups(this, DumpDecls);

284}

285

286

287

288

289

294

297 ASTDumper P(OS, Context, Context.getDiagnostics().getShowColors());

299}

300

305

306

307

308

309

311 const auto *FC = dyn_cast(this);

312 if (!FC)

313 return;

314 ASTDumper Dumper(llvm::errs(), false);

315 Dumper.Visit(FC, FC);

316}

317

320 const auto *FC = dyn_cast(this);

321 if (!FC)

322 return;

323 ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());

324 Dumper.Visit(FC, FC);

325}

326

328 const auto *FC = dyn_cast(this);

329 if (!FC)

330 return;

331 ASTDumper Dumper(llvm::errs(), true);

332 Dumper.Visit(FC, FC);

333}

334

335

336

337

338

340 ASTDumper Dumper(llvm::errs(), false);

342}

343

346 ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());

347 Dumper.Visit(*this, Context.getPointerType(Context.CharTy));

348}

349

350

351

352

353

355 dump(llvm::errs());

356}

357

361 P.Visit(this);

362}

363

364

365

366

367

368

369

370

371

373 ASTDumper Dumper(llvm::errs(), false);

374 Dumper.Visit(*this);

375}

376

379 ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());

380 Dumper.Visit(*this);

381}

382

383

384

385

386

388 ASTDumper Dumper(llvm::errs(), false);

389 Dumper.Visit(*this);

390}

391

394 ASTDumper Dumper(OS, Context, Context.getDiagnostics().getShowColors());

395 Dumper.Visit(*this);

396}

This file provides AST data structures related to concepts.

Defines the clang::ASTContext interface.

Defines the SourceManager interface.

void dump() const

Definition ASTDumper.cpp:339

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

SourceManager & getSourceManager()

comments::CommandTraits & getCommentCommandTraits() const

const clang::PrintingPolicy & getPrintingPolicy() const

DiagnosticsEngine & getDiagnostics() const

void dumpTemplateDeclSpecialization(const SpecializationDecl *D, bool DumpExplicitInst, bool DumpRefOnly)

Definition ASTDumper.cpp:112

void dumpLookups(const DeclContext *DC, bool DumpDecls)

Definition ASTDumper.cpp:52

void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst)

Definition ASTDumper.cpp:148

void dumpInvalidDeclContext(const DeclContext *DC)

Definition ASTDumper.cpp:25

void VisitVarTemplateDecl(const VarTemplateDecl *D)

Definition ASTDumper.cpp:171

void VisitClassTemplateDecl(const ClassTemplateDecl *D)

Definition ASTDumper.cpp:167

void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)

Definition ASTDumper.cpp:160

void Visit(const Decl *D, bool VisitLocs=false)

bool getDeserialize() const

void setDeserialize(bool D)

TraversalKind GetTraversalKind() const

void dumpTemplateParameters(const TemplateParameterList *TPL)

Declaration of a class template.

void dump() const

Definition ASTDumper.cpp:354

TemplateDecl * getNamedConcept() const

The results of name lookup within a DeclContext.

DeclListNode::iterator iterator

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

DeclContext * getParent()

getParent - Returns the containing DeclContext.

void dumpAsDecl() const

Definition ASTDumper.cpp:245

lookups_range noload_lookups(bool PreserveInternalState) const

void dumpLookups() const

Definition ASTDumper.cpp:270

bool hasExternalVisibleStorage() const

Whether this DeclContext has external storage containing additional declarations that are visible in ...

bool isTranslationUnit() const

lookups_range lookups() const

bool hasValidDeclKind() const

DeclContext * getPrimaryContext()

getPrimaryContext - There may be many different declarations of the same entity (including forward de...

Decl::Kind getDeclKind() const

Decl - This represents one declaration (or definition), e.g.

Decl * getPreviousDecl()

Retrieve the previous declaration that declares the same entity as this declaration,...

ASTContext & getASTContext() const LLVM_READONLY

void dumpColor() const

Definition ASTDumper.cpp:239

bool isCanonicalDecl() const

Whether this particular Decl is a canonical one.

void dump() const

Definition ASTDumper.cpp:220

The name of a declaration.

Declaration of a template function.

A (possibly-)qualified type.

void dump() const

Definition ASTDumper.cpp:185

This class handles loading and caching of source files into memory.

void dump() const

Dumps the specified AST fragment and all subtrees to llvm::errs().

Definition ASTDumper.cpp:290

void dumpColor() const

dumpColor - same as dump(), but forces color highlighting.

Definition ASTDumper.cpp:301

void dump() const

Debugging aid that dumps the template argument to standard error.

Definition ASTDumper.cpp:387

The base class of all kinds of template declarations (e.g., class, function, etc.).

NamedDecl * getTemplatedDecl() const

Get the underlying, templated declaration.

TemplateParameterList * getTemplateParameters() const

Get the list of template parameters.

void dump() const

Debugging aid that dumps the template name to standard error.

Definition ASTDumper.cpp:372

void dump() const

Definition ASTDumper.cpp:207

void dump() const

Definition ASTDumper.cpp:196

Declaration of a variable template.

The JSON file list parser is used to communicate input to InstallAPI.

static const TerminalColor NullColor

ASTDumpOutputFormat

Used to specify the format for printing AST dump information.

static const TerminalColor DeclNameColor

static const TerminalColor UndeserializedColor

static const TerminalColor DeclKindNameColor

@ TK_AsIs

Will traverse all child nodes.

@ TSK_ExplicitInstantiationDefinition

This template specialization was instantiated from a template due to an explicit instantiation defini...

@ TSK_ExplicitInstantiationDeclaration

This template specialization was instantiated from a template due to an explicit instantiation declar...

@ TSK_ExplicitSpecialization

This template specialization was declared or defined by an explicit specialization (C++ [temp....

@ TSK_ImplicitInstantiation

This template specialization was implicitly instantiated from a template.

@ TSK_Undeclared

This template specialization was formed from a template-id but has not yet been declared,...

U cast(CodeGen::Address addr)

int const char * function