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

1

2

3

4

5

6

7

8

9

10

11

12

15

16using namespace clang;

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91namespace {

95

98 }

99

102 }

103

106 }

107

109

110

111

112

114

121

124 }

125

128 }

129

132 }

133

136 }

137

140 }

141

144 }

147 }

150 }

153 }

156 }

157

160 }

161

164 }

165

168 }

169

173 }

174

177 }

178

181 }

182

185 }

186

189

190

191

193

194

195

197 }

198

199

205

206#define DEF_TRAVERSE_TMPL_INST(kind) \

207 bool TraverseTemplateInstantiations(kind##TemplateDecl *D) { \

208 return Visitor.TraverseTemplateInstantiations(D); \

209 }

213#undef DEF_TRAVERSE_TMPL_INST

214

215

216#define ABSTRACT_DECL(DECL)

217#define DECL(CLASS, BASE) \

218 bool Traverse##CLASS##Decl(CLASS##Decl *D) { \

219 return Visitor.Traverse##CLASS##Decl(D); \

220 }

221#include "clang/AST/DeclNodes.inc"

222

223#define DECL(CLASS, BASE) \

224 bool Visit##CLASS##Decl(CLASS##Decl *D) { \

225 return Visitor.Visit##CLASS##Decl(D); \

226 }

227#include "clang/AST/DeclNodes.inc"

228

229

230#define ABSTRACT_STMT(STMT)

231#define STMT(CLASS, PARENT) \

232 bool Traverse##CLASS(CLASS *S) { return Visitor.Traverse##CLASS(S); }

233#include "clang/AST/StmtNodes.inc"

234

235#define STMT(CLASS, PARENT) \

236 bool Visit##CLASS(CLASS *S) { return Visitor.Visit##CLASS(S); }

237#include "clang/AST/StmtNodes.inc"

238

239

240#define ABSTRACT_TYPE(CLASS, BASE)

241#define TYPE(CLASS, BASE) \

242 bool Traverse##CLASS##Type(CLASS##Type *T) { \

243 return Visitor.Traverse##CLASS##Type(T); \

244 }

245#include "clang/AST/TypeNodes.inc"

246

247#define TYPE(CLASS, BASE) \

248 bool Visit##CLASS##Type(CLASS##Type *T) { \

249 return Visitor.Visit##CLASS##Type(T); \

250 }

251#include "clang/AST/TypeNodes.inc"

252

253

254#define ABSTRACT_TYPELOC(CLASS, BASE)

255#define TYPELOC(CLASS, BASE) \

256 bool Traverse##CLASS##TypeLoc(CLASS##TypeLoc TL) { \

257 return Visitor.Traverse##CLASS##TypeLoc(TL); \

258 }

259#include "clang/AST/TypeLocNodes.def"

260

261#define TYPELOC(CLASS, BASE) \

262 bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { \

263 return Visitor.Visit##CLASS##TypeLoc(TL); \

264 }

265#include "clang/AST/TypeLocNodes.def"

266};

267}

268

270

272 return Impl(*this).RecursiveASTVisitor::TraverseAST(AST);

273}

274

276 return Impl(*this).RecursiveASTVisitor::TraverseAttr(At);

277}

278

281 return Impl(*this).RecursiveASTVisitor::TraverseConstructorInitializer(

283}

284

286 return Impl(*this).RecursiveASTVisitor::TraverseDecl(D);

287}

288

292 return Impl(*this).RecursiveASTVisitor::TraverseLambdaCapture(LE, C,

294}

295

297 return Impl(*this).RecursiveASTVisitor::TraverseStmt(S);

298}

299

302 return Impl(*this).RecursiveASTVisitor::TraverseTemplateArgument(Arg);

303}

304

307 return Impl(*this).RecursiveASTVisitor::TraverseTemplateArguments(Args);

308}

309

312 return Impl(*this).RecursiveASTVisitor::TraverseTemplateArgumentLoc(

313 ArgLoc);

314}

315

317 return Impl(*this).RecursiveASTVisitor::TraverseTemplateName(Template);

318}

319

321 return Impl(*this).RecursiveASTVisitor::TraverseType(T);

322}

323

325 return Impl(*this).RecursiveASTVisitor::TraverseTypeLoc(TL);

326}

327

330 return Impl(*this).RecursiveASTVisitor::TraverseTypeConstraint(C);

331}

334 return Impl(*this).RecursiveASTVisitor::TraverseObjCProtocolLoc(

335 ProtocolLoc);

336}

337

340 return Impl(*this).RecursiveASTVisitor::TraverseConceptRequirement(R);

341}

344 return Impl(*this).RecursiveASTVisitor::TraverseConceptTypeRequirement(

345 R);

346}

349 return Impl(*this).RecursiveASTVisitor::TraverseConceptExprRequirement(

350 R);

351}

354 return Impl(*this)

355 .RecursiveASTVisitor::TraverseConceptNestedRequirement(R);

356}

357

360 return Impl(*this).RecursiveASTVisitor::TraverseConceptReference(CR);

361}

362

365 return Impl(*this).RecursiveASTVisitor::TraverseCXXBaseSpecifier(Base);

366}

367

370 return Impl(*this).RecursiveASTVisitor::TraverseDeclarationNameInfo(

371 NameInfo);

372}

373

376 return Impl(*this).RecursiveASTVisitor::TraverseNestedNameSpecifier(

377 NNS);

378}

379

382 return Impl(*this).RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(

383 NNS);

384}

385

387 return Impl(*this).RecursiveASTVisitor::dataTraverseNode(S, nullptr);

388}

389

390#define DEF_TRAVERSE_TMPL_INST(kind) \

391 bool DynamicRecursiveASTVisitor::TraverseTemplateInstantiations( \

392 kind##TemplateDecl *D) { \

393 return Impl(*this) \

394 .RecursiveASTVisitor::TraverseTemplateInstantiations(D); \

395 }

399#undef DEF_TRAVERSE_TMPL_INST

400

401

402#define ABSTRACT_DECL(DECL)

403#define DECL(CLASS, BASE) \

404 bool DynamicRecursiveASTVisitor::Traverse##CLASS##Decl(CLASS##Decl *D) { \

405 return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##Decl(D); \

406 } \

407 bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Decl(CLASS##Decl *D) { \

408 return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##Decl(D); \

409 }

410#include "clang/AST/DeclNodes.inc"

411

412

413#define ABSTRACT_STMT(STMT)

414#define STMT(CLASS, PARENT) \

415 bool DynamicRecursiveASTVisitor::Traverse##CLASS(CLASS *S) { \

416 return Impl(*this).RecursiveASTVisitor::Traverse##CLASS(S); \

417 }

418#include "clang/AST/StmtNodes.inc"

419

420#define STMT(CLASS, PARENT) \

421 bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS(CLASS *S) { \

422 return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS(S); \

423 }

424#include "clang/AST/StmtNodes.inc"

425

426

427#define ABSTRACT_TYPE(CLASS, BASE)

428#define TYPE(CLASS, BASE) \

429 bool DynamicRecursiveASTVisitor::Traverse##CLASS##Type(CLASS##Type *T) { \

430 return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##Type(T); \

431 } \

432 bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##Type(CLASS##Type *T) { \

433 return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##Type(T); \

434 }

435#include "clang/AST/TypeNodes.inc"

436

437#define ABSTRACT_TYPELOC(CLASS, BASE)

438#define TYPELOC(CLASS, BASE) \

439 bool DynamicRecursiveASTVisitor::Traverse##CLASS##TypeLoc( \

440 CLASS##TypeLoc TL) { \

441 return Impl(*this).RecursiveASTVisitor::Traverse##CLASS##TypeLoc( \

442 TL); \

443 }

444#include "clang/AST/TypeLocNodes.def"

445

446#define TYPELOC(CLASS, BASE) \

447 bool DynamicRecursiveASTVisitor::WalkUpFrom##CLASS##TypeLoc( \

448 CLASS##TypeLoc TL) { \

449 return Impl(*this).RecursiveASTVisitor::WalkUpFrom##CLASS##TypeLoc( \

450 TL); \

451 }

452#include "clang/AST/TypeLocNodes.def"

#define DEF_TRAVERSE_TMPL_INST(kind)

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

Attr - This represents one attribute.

Represents a base class of a C++ class.

Represents a C++ base or member initializer.

A reference to a concept and its template args, as it appears in the code.

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

Recursive AST visitor that supports extension via dynamic dispatch.

virtual bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)

Recursively visit a name with its location information.

virtual bool dataTraverseStmtPost(Stmt *S)

Invoked after visiting a statement or expression via data recursion.

virtual bool TraverseDecl(Decl *D)

Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...

virtual bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R)

virtual bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)

Recursively visit a C++ nested-name-specifier.

virtual bool VisitAttr(Attr *A)

Visit a node.

bool ShouldVisitLambdaBody

Whether this visitor should recurse into lambda body.

virtual bool TraverseTypeLoc(TypeLoc TL)

Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...

virtual bool dataTraverseStmtPre(Stmt *S)

Invoked before visiting a statement or expression via data recursion.

virtual bool TraverseConceptRequirement(concepts::Requirement *R)

virtual bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc)

Recursively visit an Objective-C protocol reference with location information.

virtual bool VisitConceptReference(ConceptReference *CR)

virtual bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)

Recursively visit a C++ nested-name-specifier with location information.

virtual bool VisitStmt(Stmt *S)

virtual bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)

Recursively visit a lambda capture.

virtual bool VisitType(Type *T)

virtual bool TraverseAttr(Attr *At)

Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...

virtual bool TraverseStmt(Stmt *S)

Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...

virtual bool TraverseConceptReference(ConceptReference *CR)

virtual bool VisitDecl(Decl *D)

virtual bool TraverseTemplateArgument(const TemplateArgument &Arg)

Recursively visit a template argument and dispatch to the appropriate method for the argument type.

virtual bool TraverseConstructorInitializer(CXXCtorInitializer *Init)

Recursively visit a constructor initializer.

bool TraverseTemplateArguments(ArrayRef< TemplateArgument > Args)

Recursively visit a set of template arguments.

virtual bool TraverseConceptExprRequirement(concepts::ExprRequirement *R)

virtual bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)

Recursively visit a template argument location and dispatch to the appropriate method for the argumen...

virtual bool dataTraverseNode(Stmt *S)

virtual bool TraverseAST(ASTContext &AST)

Recursively visits an entire AST, starting from the TranslationUnitDecl.

virtual bool TraverseType(QualType T)

Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...

virtual bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)

Recursively visit a base specifier.

virtual bool TraverseTypeConstraint(const TypeConstraint *C)

Traverse a concept (requirement).

bool ShouldWalkTypesOfTypeLocs

Whether this visitor should recurse into the types of TypeLocs.

bool ShouldVisitImplicitCode

Whether this visitor should recurse into implicit code, e.g.

virtual bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R)

virtual bool VisitTypeLoc(TypeLoc TL)

bool ShouldVisitTemplateInstantiations

Whether this visitor should recurse into template instantiations.

virtual bool TraverseTemplateName(TemplateName Template)

Recursively visit a template name and dispatch to the appropriate method.

This represents one expression.

Describes the capture of a variable or of this, or of a C++1y init-capture.

A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...

A C++ nested-name-specifier augmented with source location information.

Represents a C++ nested name specifier, such as "\::std::vector::".

A (possibly-)qualified type.

A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...

bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)

Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...

bool TraverseTemplateArgument(const TemplateArgument &Arg)

Recursively visit a template argument and dispatch to the appropriate method for the argument type.

bool TraverseConceptRequirement(concepts::Requirement *R)

bool TraverseType(QualType T)

Recursively visit a type, by dispatching to Traverse*Type() based on the argument's getTypeClass() pr...

bool dataTraverseStmtPre(Stmt *S)

Invoked before visiting a statement or expression via data recursion.

bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc)

Recursively visit an Objective-C protocol reference with location information.

bool TraverseConceptExprRequirement(concepts::ExprRequirement *R)

bool TraverseAST(ASTContext &AST)

Recursively visits an entire AST, starting from the TranslationUnitDecl.

bool shouldVisitTemplateInstantiations() const

Return whether this visitor should recurse into template instantiations.

bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)

Recursively visit a template argument location and dispatch to the appropriate method for the argumen...

bool dataTraverseStmtPost(Stmt *S)

Invoked after visiting a statement or expression via data recursion.

bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)

Recursively visit a C++ nested-name-specifier with location information.

bool TraverseTemplateName(TemplateName Template)

Recursively visit a template name and dispatch to the appropriate method.

bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS)

Recursively visit a C++ nested-name-specifier.

bool shouldVisitImplicitCode() const

Return whether this visitor should recurse into implicit code, e.g., implicit constructors and destru...

bool TraverseConceptReference(ConceptReference *CR)

Recursively visit concept reference with location information.

bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue)

bool TraverseDecl(Decl *D)

Recursively visit a declaration, by dispatching to Traverse*Decl() based on the argument's dynamic ty...

bool TraverseTypeLoc(TypeLoc TL)

Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...

bool TraverseTypeConstraint(const TypeConstraint *C)

bool VisitTypeLoc(TypeLoc TL)

bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init)

Recursively visit a lambda capture.

bool VisitConceptReference(ConceptReference *CR)

bool shouldTraversePostOrder() const

Return whether this visitor should traverse post-order.

bool shouldVisitLambdaBody() const

Return whether this visitor should recurse into lambda body.

bool TraverseAttr(Attr *At)

Recursively visit an attribute, by dispatching to Traverse*Attr() based on the argument's dynamic typ...

bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R)

bool shouldWalkTypesOfTypeLocs() const

Return whether this visitor should recurse into the types of TypeLocs.

bool TraverseDeclarationNameInfo(DeclarationNameInfo NameInfo)

Recursively visit a name with its location information.

bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &Base)

Recursively visit a base specifier.

bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R)

bool TraverseConstructorInitializer(CXXCtorInitializer *Init)

Recursively visit a constructor initializer.

Stmt - This represents one statement.

Location wrapper for a TemplateArgument.

Represents a template argument.

Represents a C++ template name within the type system.

Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...

Base wrapper for a particular "section" of type source info.

The base class of the type hierarchy.

A requires-expression requirement which queries the validity and properties of an expression ('simple...

A requires-expression requirement which is satisfied when a general constraint expression is satisfie...

A static requirement that can be used in a requires-expression to check properties of types and expre...

A requires-expression requirement which queries the existence of a type name or type template special...

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

const FunctionProtoType * T

@ Class

The "class" keyword introduces the elaborated-type-specifier.

DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...