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

27 if (!DC) {

29 OS << "<<>>";

30 return;

31 }

32

33

34

35

36

37

38 {

40 OS << "DeclContext";

41 }

43 OS << " <";

44 {

47 }

48 OS << ">";

49 });

50}

51

54 OS << "StoredDeclsMap ";

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

73 OS << "DeclarationName ";

74 {

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

77 }

78

80 RI != RE; ++RI) {

83

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

85 OS << " hidden";

86

87

88 if (DumpDecls) {

89

90 std::function<void(Decl *)> DumpWithPrev = [&](Decl *D) {

92 DumpWithPrev(Prev);

94 };

95 DumpWithPrev(*RI);

96 }

97 });

98 }

99 });

100 }

101

102 if (HasUndeserializedLookups) {

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 = cast(RedeclWithBadType);

121 switch (Redecl->getTemplateSpecializationKind()) {

124 if (!DumpExplicitInst)

125 break;

126 [[fallthrough]];

129 if (DumpRefOnly)

131 else

133 DumpedAny = true;

134 break;

136 break;

137 }

138 }

139

140

141 if (!DumpedAny)

143}

144

145template

148

149 Visit(D->getTemplatedDecl());

150

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

155 }

156}

157

159

160

161

163}

164

167}

168

171}

172

173

174

175

176

178 if (msg)

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

181}

182

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

185 Dumper.Visit(*this);

186}

187

191 Dumper.Visit(*this);

192}

193

195

196LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS,

198 QualType(this, 0).dump(OS, Context);

199}

200

201

202

203

204

206 ASTDumper(llvm::errs(), false).Visit(*this);

207}

208

212}

213

214

215

216

217

219

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

224

228 (void)Deserialize;

229 P.Visit(this);

230 } else {

232 P.setDeserialize(Deserialize);

233 P.Visit(this);

234 }

235}

236

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

240 P.Visit(this);

241}

242

245}

246

248

249

250

251

252

253

254

256 const auto *D = cast(this);

258 } else {

259

260

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

264 P.dumpInvalidDeclContext(this);

265 }

266}

267

270}

271

273 bool DumpDecls,

274 bool Deserialize) const {

278 const ASTContext &Ctx = cast(DC)->getASTContext();

280 P.setDeserialize(Deserialize);

281 P.dumpLookups(this, DumpDecls);

282}

283

284

285

286

287

289 ASTDumper P(llvm::errs(), false);

290 P.Visit(this);

291}

292

296 P.Visit(this);

297}

298

300 ASTDumper P(llvm::errs(), true);

301 P.Visit(this);

302}

303

304

305

306

307

309 const auto *FC = dyn_cast(this);

310 if (!FC)

311 return;

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

313 Dumper.Visit(FC, FC);

314}

315

318 const auto *FC = dyn_cast(this);

319 if (!FC)

320 return;

322 Dumper.Visit(FC, FC);

323}

324

326 const auto *FC = dyn_cast(this);

327 if (!FC)

328 return;

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

330 Dumper.Visit(FC, FC);

331}

332

333

334

335

336

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

340}

341

346}

347

348

349

350

351

353 dump(llvm::errs());

354}

355

359 P.Visit(this);

360}

361

362

363

364

365

366

367

368

369

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

372 Dumper.Visit(*this);

373}

374

378 Dumper.Visit(*this);

379}

380

381

382

383

384

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

387 Dumper.Visit(*this);

388}

389

393 Dumper.Visit(*this);

394}

This file provides AST data structures related to concepts.

Defines the clang::ASTContext interface.

Defines the SourceManager interface.

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

SourceManager & getSourceManager()

comments::CommandTraits & getCommentCommandTraits() const

QualType getPointerType(QualType T) const

Return the uniqued reference to the type for a pointer to the specified type.

const clang::PrintingPolicy & getPrintingPolicy() const

DiagnosticsEngine & getDiagnostics() const

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

void dumpLookups(const DeclContext *DC, bool DumpDecls)

void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst)

void dumpInvalidDeclContext(const DeclContext *DC)

void VisitVarTemplateDecl(const VarTemplateDecl *D)

void VisitClassTemplateDecl(const ClassTemplateDecl *D)

void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)

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

bool getDeserialize() const

TraversalKind GetTraversalKind() const

void dumpTemplateParameters(const TemplateParameterList *TPL)

Declaration of a class template.

ConceptDecl * getNamedConcept() const

The results of name lookup within a DeclContext.

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.

lookups_range noload_lookups(bool PreserveInternalState) const

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

bool isCanonicalDecl() const

Whether this particular Decl is a canonical one.

redecl_range redecls() const

Returns an iterator range for all the redeclarations of the same decl.

The name of a declaration.

Declaration of a template function.

A (possibly-)qualified type.

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().

void dumpColor() const

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

void dump() const

Debugging aid that dumps the template argument to standard error.

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

void dump() const

Debugging aid that dumps the template name to standard error.

void dumpPointer(const void *Ptr)

void dumpDeclRef(const Decl *D, StringRef Label={})

void dumpBareDeclRef(const Decl *D)

void AddChild(Fn DoAddChild)

Add a child of the current node. Calls DoAddChild without arguments.

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

if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))

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,...