clang  10.0.0git
ASTNodeTraverser.h
Go to the documentation of this file.
1 //===--- ASTNodeTraverser.h - Traversal of AST nodes ----------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the AST traversal facilities. Other users
10 // of this class may make use of the same traversal logic by inheriting it,
11 // similar to RecursiveASTVisitor.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_AST_ASTNODETRAVERSER_H
16 #define LLVM_CLANG_AST_ASTNODETRAVERSER_H
17 
18 #include "clang/AST/AttrVisitor.h"
20 #include "clang/AST/DeclVisitor.h"
21 #include "clang/AST/LocInfoType.h"
22 #include "clang/AST/StmtVisitor.h"
24 #include "clang/AST/TypeVisitor.h"
25 
26 namespace clang {
27 
28 /**
29 
30 ASTNodeTraverser traverses the Clang AST for dumping purposes.
31 
32 The `Derived::doGetNodeDelegate()` method is required to be an accessible member
33 which returns a reference of type `NodeDelegateType &` which implements the
34 following interface:
35 
36 struct {
37  template <typename Fn> void AddChild(Fn DoAddChild);
38  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild);
39 
40  void Visit(const comments::Comment *C, const comments::FullComment *FC);
41  void Visit(const Attr *A);
42  void Visit(const TemplateArgument &TA, SourceRange R = {},
43  const Decl *From = nullptr, StringRef Label = {});
44  void Visit(const Stmt *Node);
45  void Visit(const Type *T);
46  void Visit(QualType T);
47  void Visit(const Decl *D);
48  void Visit(const CXXCtorInitializer *Init);
49  void Visit(const OMPClause *C);
50  void Visit(const BlockDecl::Capture &C);
51  void Visit(const GenericSelectionExpr::ConstAssociation &A);
52 };
53 */
54 template <typename Derived, typename NodeDelegateType>
56  : public ConstDeclVisitor<Derived>,
57  public ConstStmtVisitor<Derived>,
58  public comments::ConstCommentVisitor<Derived, void,
59  const comments::FullComment *>,
60  public TypeVisitor<Derived>,
61  public ConstAttrVisitor<Derived>,
62  public ConstTemplateArgumentVisitor<Derived> {
63 
64  /// Indicates whether we should trigger deserialization of nodes that had
65  /// not already been loaded.
66  bool Deserialize = false;
67 
70 
71  NodeDelegateType &getNodeDelegate() {
72  return getDerived().doGetNodeDelegate();
73  }
74  Derived &getDerived() { return *static_cast<Derived *>(this); }
75 
76 public:
77  void setDeserialize(bool D) { Deserialize = D; }
78  bool getDeserialize() const { return Deserialize; }
79 
80  void SetTraversalKind(ast_type_traits::TraversalKind TK) { Traversal = TK; }
81 
82  void Visit(const Decl *D) {
83  getNodeDelegate().AddChild([=] {
84  getNodeDelegate().Visit(D);
85  if (!D)
86  return;
87 
89 
90  for (const auto &A : D->attrs())
91  Visit(A);
92 
93  if (const comments::FullComment *Comment =
95  Visit(Comment, Comment);
96 
97  // Decls within functions are visited by the body.
98  if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D)) {
99  if (const auto *DC = dyn_cast<DeclContext>(D))
100  dumpDeclContext(DC);
101  }
102  });
103  }
104 
105  void Visit(const Stmt *Node, StringRef Label = {}) {
106  getNodeDelegate().AddChild(Label, [=] {
107  const Stmt *S = Node;
108 
109  if (auto *E = dyn_cast_or_null<Expr>(S)) {
110  switch (Traversal) {
112  break;
114  S = E->IgnoreParenImpCasts();
115  break;
117  S = E->IgnoreUnlessSpelledInSource();
118  break;
119  }
120  }
121 
122  getNodeDelegate().Visit(S);
123 
124  if (!S) {
125  return;
126  }
127 
129 
130  // Some statements have custom mechanisms for dumping their children.
131  if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S))
132  return;
133 
134  if (isa<LambdaExpr>(S) &&
136  return;
137 
138  for (const Stmt *SubStmt : S->children())
139  Visit(SubStmt);
140  });
141  }
142 
143  void Visit(QualType T) {
144  SplitQualType SQT = T.split();
145  if (!SQT.Quals.hasQualifiers())
146  return Visit(SQT.Ty);
147 
148  getNodeDelegate().AddChild([=] {
149  getNodeDelegate().Visit(T);
150  Visit(T.split().Ty);
151  });
152  }
153 
154  void Visit(const Type *T) {
155  getNodeDelegate().AddChild([=] {
156  getNodeDelegate().Visit(T);
157  if (!T)
158  return;
160 
161  QualType SingleStepDesugar =
163  if (SingleStepDesugar != QualType(T, 0))
164  Visit(SingleStepDesugar);
165  });
166  }
167 
168  void Visit(const Attr *A) {
169  getNodeDelegate().AddChild([=] {
170  getNodeDelegate().Visit(A);
172  });
173  }
174 
175  void Visit(const CXXCtorInitializer *Init) {
176  getNodeDelegate().AddChild([=] {
177  getNodeDelegate().Visit(Init);
178  Visit(Init->getInit());
179  });
180  }
181 
182  void Visit(const TemplateArgument &A, SourceRange R = {},
183  const Decl *From = nullptr, const char *Label = nullptr) {
184  getNodeDelegate().AddChild([=] {
185  getNodeDelegate().Visit(A, R, From, Label);
187  });
188  }
189 
190  void Visit(const BlockDecl::Capture &C) {
191  getNodeDelegate().AddChild([=] {
192  getNodeDelegate().Visit(C);
193  if (C.hasCopyExpr())
194  Visit(C.getCopyExpr());
195  });
196  }
197 
198  void Visit(const OMPClause *C) {
199  getNodeDelegate().AddChild([=] {
200  getNodeDelegate().Visit(C);
201  for (const auto *S : C->children())
202  Visit(S);
203  });
204  }
205 
207  getNodeDelegate().AddChild([=] {
208  getNodeDelegate().Visit(A);
209  if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
210  Visit(TSI->getType());
211  Visit(A.getAssociationExpr());
212  });
213  }
214 
215  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
216  getNodeDelegate().AddChild([=] {
217  getNodeDelegate().Visit(C, FC);
218  if (!C) {
219  return;
220  }
221  comments::ConstCommentVisitor<Derived, void,
222  const comments::FullComment *>::visit(C,
223  FC);
225  E = C->child_end();
226  I != E; ++I)
227  Visit(*I, FC);
228  });
229  }
230 
232  // FIXME: Improve this with a switch or a visitor pattern.
233  if (const auto *D = N.get<Decl>())
234  Visit(D);
235  else if (const auto *S = N.get<Stmt>())
236  Visit(S);
237  else if (const auto *QT = N.get<QualType>())
238  Visit(*QT);
239  else if (const auto *T = N.get<Type>())
240  Visit(T);
241  else if (const auto *C = N.get<CXXCtorInitializer>())
242  Visit(C);
243  else if (const auto *C = N.get<OMPClause>())
244  Visit(C);
245  else if (const auto *T = N.get<TemplateArgument>())
246  Visit(*T);
247  }
248 
249  void dumpDeclContext(const DeclContext *DC) {
250  if (!DC)
251  return;
252 
253  for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
254  Visit(D);
255  }
256 
258  if (!TPL)
259  return;
260 
261  for (const auto &TP : *TPL)
262  Visit(TP);
263 
264  if (const Expr *RC = TPL->getRequiresClause())
265  Visit(RC);
266  }
267 
268  void
270  if (!TALI)
271  return;
272 
273  for (const auto &TA : TALI->arguments())
275  }
276 
278  const Decl *From = nullptr,
279  const char *Label = nullptr) {
280  Visit(A.getArgument(), A.getSourceRange(), From, Label);
281  }
282 
284  for (unsigned i = 0, e = TAL.size(); i < e; ++i)
285  Visit(TAL[i]);
286  }
287 
288  void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams) {
289  if (!typeParams)
290  return;
291 
292  for (const auto &typeParam : *typeParams) {
293  Visit(typeParam);
294  }
295  }
296 
298  void VisitLocInfoType(const LocInfoType *T) {
300  }
303  Visit(T->getPointeeType());
304  }
306  Visit(T->getPointeeType());
307  }
309  Visit(T->getClass());
310  Visit(T->getPointeeType());
311  }
312  void VisitArrayType(const ArrayType *T) { Visit(T->getElementType()); }
314  VisitArrayType(T);
315  Visit(T->getSizeExpr());
316  }
318  Visit(T->getElementType());
319  Visit(T->getSizeExpr());
320  }
322  Visit(T->getElementType());
323  Visit(T->getSizeExpr());
324  }
325  void VisitVectorType(const VectorType *T) { Visit(T->getElementType()); }
329  for (const QualType &PT : T->getParamTypes())
330  Visit(PT);
331  }
333  Visit(T->getUnderlyingExpr());
334  }
336  Visit(T->getUnderlyingExpr());
337  }
339  Visit(T->getBaseType());
340  }
342  // FIXME: AttrKind
343  Visit(T->getModifiedType());
344  }
347  }
348  void
351  Visit(T->getArgumentPack());
352  }
354  for (const auto &Arg : *T)
355  Visit(Arg);
356  if (T->isTypeAlias())
357  Visit(T->getAliasedType());
358  }
360  Visit(T->getPointeeType());
361  }
362  void VisitAtomicType(const AtomicType *T) { Visit(T->getValueType()); }
363  void VisitPipeType(const PipeType *T) { Visit(T->getElementType()); }
366  if (!T->isSugared())
367  Visit(T->getPattern());
368  }
369  // FIXME: ElaboratedType, DependentNameType,
370  // DependentTemplateSpecializationType, ObjCObjectType
371 
373 
375  if (const Expr *Init = D->getInitExpr())
376  Visit(Init);
377  }
378 
380  if (const auto *FTSI = D->getTemplateSpecializationInfo())
381  dumpTemplateArgumentList(*FTSI->TemplateArguments);
382 
383  if (D->param_begin())
384  for (const auto *Parameter : D->parameters())
385  Visit(Parameter);
386 
387  if (const Expr *TRC = D->getTrailingRequiresClause())
388  Visit(TRC);
389 
390  if (const auto *C = dyn_cast<CXXConstructorDecl>(D))
391  for (const auto *I : C->inits())
392  Visit(I);
393 
395  Visit(D->getBody());
396  }
397 
398  void VisitFieldDecl(const FieldDecl *D) {
399  if (D->isBitField())
400  Visit(D->getBitWidth());
401  if (Expr *Init = D->getInClassInitializer())
402  Visit(Init);
403  }
404 
405  void VisitVarDecl(const VarDecl *D) {
406  if (D->hasInit())
407  Visit(D->getInit());
408  }
409 
411  VisitVarDecl(D);
412  for (const auto *B : D->bindings())
413  Visit(B);
414  }
415 
416  void VisitBindingDecl(const BindingDecl *D) {
417  if (const auto *E = D->getBinding())
418  Visit(E);
419  }
420 
422  Visit(D->getAsmString());
423  }
424 
425  void VisitCapturedDecl(const CapturedDecl *D) { Visit(D->getBody()); }
426 
428  for (const auto *E : D->varlists())
429  Visit(E);
430  }
431 
433  Visit(D->getCombiner());
434  if (const auto *Initializer = D->getInitializer())
436  }
437 
439  for (const auto *C : D->clauselists())
440  Visit(C);
441  }
442 
444  Visit(D->getInit());
445  }
446 
448  for (const auto *E : D->varlists())
449  Visit(E);
450  for (const auto *C : D->clauselists())
451  Visit(C);
452  }
453 
454  template <typename SpecializationDecl>
455  void dumpTemplateDeclSpecialization(const SpecializationDecl *D) {
456  for (const auto *RedeclWithBadType : D->redecls()) {
457  // FIXME: The redecls() range sometimes has elements of a less-specific
458  // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
459  // us TagDecls, and should give CXXRecordDecls).
460  auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
461  if (!Redecl) {
462  // Found the injected-class-name for a class template. This will be
463  // dumped as part of its surrounding class so we don't need to dump it
464  // here.
465  assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
466  "expected an injected-class-name");
467  continue;
468  }
469  Visit(Redecl);
470  }
471  }
472 
473  template <typename TemplateDecl>
476 
477  Visit(D->getTemplatedDecl());
478 
479  for (const auto *Child : D->specializations())
481  }
482 
484  Visit(D->getUnderlyingType());
485  }
486 
489  Visit(D->getTemplatedDecl());
490  }
491 
493  Visit(D->getAssertExpr());
494  Visit(D->getMessage());
495  }
496 
498  dumpTemplateDecl(D);
499  }
500 
502  dumpTemplateDecl(D);
503  }
504 
508  }
509 
514  }
515 
518  Visit(D->getSpecialization());
520  }
522 
525  }
526 
527  void
530  VisitVarDecl(D);
531  }
532 
537  }
538 
540  if (const auto *TC = D->getTypeConstraint())
541  if (TC->hasExplicitTemplateArgs())
542  for (const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
543  dumpTemplateArgumentLoc(ArgLoc);
544  if (D->hasDefaultArgument())
547  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
548  }
549 
551  if (const auto *E = D->getPlaceholderTypeConstraint())
552  Visit(E);
553  if (D->hasDefaultArgument())
556  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
557  }
558 
561  if (D->hasDefaultArgument())
564  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
565  }
566 
567  void VisitConceptDecl(const ConceptDecl *D) {
569  Visit(D->getConstraintExpr());
570  }
571 
573  if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl()))
574  Visit(TD->getTypeForDecl());
575  }
576 
577  void VisitFriendDecl(const FriendDecl *D) {
578  if (!D->getFriendType())
579  Visit(D->getFriendDecl());
580  }
581 
584  dumpDeclContext(D);
585  else
586  for (const ParmVarDecl *Parameter : D->parameters())
587  Visit(Parameter);
588 
589  if (D->hasBody())
590  Visit(D->getBody());
591  }
592 
595  }
596 
599  }
600 
602  for (const auto &I : D->inits())
603  Visit(I);
604  }
605 
606  void VisitBlockDecl(const BlockDecl *D) {
607  for (const auto &I : D->parameters())
608  Visit(I);
609 
610  for (const auto &I : D->captures())
611  Visit(I);
612  Visit(D->getBody());
613  }
614 
615  void VisitDeclStmt(const DeclStmt *Node) {
616  for (const auto &D : Node->decls())
617  Visit(D);
618  }
619 
621  for (const auto *A : Node->getAttrs())
622  Visit(A);
623  }
624 
625  void VisitCXXCatchStmt(const CXXCatchStmt *Node) {
626  Visit(Node->getExceptionDecl());
627  }
628 
629  void VisitCapturedStmt(const CapturedStmt *Node) {
630  Visit(Node->getCapturedDecl());
631  }
632 
634  for (const auto *C : Node->clauses())
635  Visit(C);
636  }
637 
638  void VisitInitListExpr(const InitListExpr *ILE) {
639  if (auto *Filler = ILE->getArrayFiller()) {
640  Visit(Filler, "array_filler");
641  }
642  }
643 
644  void VisitBlockExpr(const BlockExpr *Node) { Visit(Node->getBlockDecl()); }
645 
647  if (Expr *Source = Node->getSourceExpr())
648  Visit(Source);
649  }
650 
653  Visit(E->getControllingExpr()->getType()); // FIXME: remove
654 
655  for (const auto Assoc : E->associations()) {
656  Visit(Assoc);
657  }
658  }
659 
660  void VisitLambdaExpr(const LambdaExpr *Node) {
662  for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
663  const auto *C = Node->capture_begin() + I;
664  if (!C->isExplicit())
665  continue;
666  if (Node->isInitCapture(C))
667  Visit(C->getCapturedVar());
668  else
669  Visit(Node->capture_init_begin()[I]);
670  }
672  for (const auto *P : Node->getCallOperator()->parameters())
673  Visit(P);
674  Visit(Node->getBody());
675  } else {
676  return Visit(Node->getLambdaClass());
677  }
678  }
679 
681  if (Node->isPartiallySubstituted())
682  for (const auto &A : Node->getPartialArguments())
683  Visit(A);
684  }
685 
687  if (const VarDecl *CatchParam = Node->getCatchParamDecl())
688  Visit(CatchParam);
689  }
690 
692  Visit(TA.getAsExpr());
693  }
695  for (const auto &TArg : TA.pack_elements())
696  Visit(TArg);
697  }
698 
699  // Implements Visit methods for Attrs.
700 #include "clang/AST/AttrNodeTraverse.inc"
701 };
702 
703 } // namespace clang
704 
705 #endif // LLVM_CLANG_AST_ASTNODETRAVERSER_H
clauselist_range clauselists()
Definition: DeclOpenMP.h:270
void dumpTemplateDeclSpecialization(const SpecializationDecl *D)
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5532
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5593
bool hasCopyExpr() const
Definition: Decl.h:4082
const Type * Ty
The locally-unqualified type.
Definition: Type.h:595
Represents a function declaration or definition.
Definition: Decl.h:1783
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2353
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:527
void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)
Expr * getCopyExpr() const
Definition: Decl.h:4083
A class which contains all the information about a particular captured value.
Definition: Decl.h:4043
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2614
QualType getElementType() const
Definition: Type.h:6173
QualType getPointeeType() const
Definition: Type.h:2627
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D)
void VisitAttributedStmt(const AttributedStmt *Node)
A (possibly-)qualified type.
Definition: Type.h:654
void dumpTemplateParameters(const TemplateParameterList *TPL)
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:325
void VisitBlockPointerType(const BlockPointerType *T)
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:193
void VisitAdjustedType(const AdjustedType *T)
void VisitPackTemplateArgument(const TemplateArgument &TA)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
void dumpTemplateArgumentList(const TemplateArgumentList &TAL)
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5417
Expr * getUnderlyingExpr() const
Definition: Type.h:4380
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node)
void VisitOMPDeclareMapperDecl(const OMPDeclareMapperDecl *D)
Stmt - This represents one statement.
Definition: Stmt.h:66
Expr * getBitWidth() const
Definition: Decl.h:2818
This represents &#39;#pragma omp allocate ...&#39; directive.
Definition: DeclOpenMP.h:422
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3422
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2941
void VisitAttributedType(const AttributedType *T)
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3173
void VisitFunctionDecl(const FunctionDecl *D)
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:299
const T * get() const
Retrieve the stored node as type T.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:434
void VisitExpressionTemplateArgument(const TemplateArgument &TA)
Represents an attribute applied to a statement.
Definition: Stmt.h:1776
The base class of the type hierarchy.
Definition: Type.h:1450
const DefArgStorage & getDefaultArgStorage() const
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2889
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:68
A container of type source information.
Definition: Type.h:6227
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6140
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
child_iterator child_begin() const
Definition: Comment.cpp:82
void Visit(const comments::Comment *C, const comments::FullComment *FC)
void dumpASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *TALI)
QualType getElementType() const
Definition: Type.h:2910
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:53
void VisitBlockExpr(const BlockExpr *Node)
Represents a variable declaration or definition.
Definition: Decl.h:820
void VisitFileScopeAsmDecl(const FileScopeAsmDecl *D)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2033
void VisitCXXCatchStmt(const CXXCatchStmt *Node)
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:414
void VisitVarTemplatePartialSpecializationDecl(const VarTemplatePartialSpecializationDecl *D)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:603
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
void Visit(const Decl *D)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:631
Represents a parameter to a function.
Definition: Decl.h:1595
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4728
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1283
PipeType - OpenCL20.
Definition: Type.h:6159
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void VisitObjCMethodDecl(const ObjCMethodDecl *D)
QualType getOriginalType() const
Definition: Type.h:2678
Represents a class template specialization, which refers to a class template with a given set of temp...
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:123
StringLiteral * getMessage()
Definition: DeclCXX.h:3789
QualType getPointeeType() const
Definition: Type.h:2731
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:329
void VisitVariableArrayType(const VariableArrayType *T)
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3971
Will traverse all child nodes.
Definition: ASTTypeTraits.h:42
void VisitGenericSelectionExpr(const GenericSelectionExpr *E)
const DefArgStorage & getDefaultArgStorage() const
Represents a member of a struct/union/class.
Definition: Decl.h:2729
A simple visitor class that helps create attribute visitors.
Definition: AttrVisitor.h:69
void VisitSizeOfPackExpr(const SizeOfPackExpr *Node)
An operation on a type.
Definition: TypeVisitor.h:64
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1307
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:138
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
Definition: DeclObjC.h:1325
Represents the result of substituting a set of types for a template type parameter pack...
Definition: Type.h:4784
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1133
void Visit(const OMPClause *C)
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:4116
void VisitOMPAllocateDecl(const OMPAllocateDecl *D)
Declaration of a function specialization at template class scope.
SourceRange getSourceRange() const LLVM_READONLY
void VisitFunctionProtoType(const FunctionProtoType *T)
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2399
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:77
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Describes an C or C++ initializer list.
Definition: Expr.h:4403
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.cpp:4748
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:3903
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:170
AssociationTy< true > ConstAssociation
Definition: Expr.h:5394
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2807
void VisitTypeOfExprType(const TypeOfExprType *T)
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2894
void VisitPackExpansionType(const PackExpansionType *T)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Definition: ExprCXX.h:1963
A simple visitor class that helps create template argument visitors.
child_range children()
Definition: Stmt.cpp:224
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:4300
void VisitUsingShadowDecl(const UsingShadowDecl *D)
const Type * getClass() const
Definition: Type.h:2867
Any part of the comment.
Definition: Comment.h:52
void VisitOMPExecutableDirective(const OMPExecutableDirective *Node)
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3663
Expr * getSizeExpr() const
Definition: Type.h:3058
void Visit(const Type *T)
void VisitCapturedDecl(const CapturedDecl *D)
const Expr * getInitExpr() const
Definition: Decl.h:2960
void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void VisitBlockDecl(const BlockDecl *D)
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1818
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4226
Represents an ObjC class declaration.
Definition: DeclObjC.h:1186
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:1240
void VisitCapturedStmt(const CapturedStmt *Node)
A binding in a decomposition declaration.
Definition: DeclCXX.h:3812
Expr * getSizeExpr() const
Definition: Type.h:3115
void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams)
void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A, const Decl *From=nullptr, const char *Label=nullptr)
QualType getElementType() const
Definition: Type.h:3211
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3195
param_iterator param_begin()
Definition: Decl.h:2411
void VisitInitListExpr(const InitListExpr *ILE)
child_range children()
void Visit(const Stmt *Node, StringRef Label={})
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3193
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
void Visit(const GenericSelectionExpr::ConstAssociation &A)
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:28
child_iterator child_end() const
Definition: Comment.cpp:96
void VisitFriendDecl(const FriendDecl *D)
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:2041
void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D)
void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:152
void VisitObjCObjectPointerType(const ObjCObjectPointerType *T)
void VisitFieldDecl(const FieldDecl *D)
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3093
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:421
QualType getElementType() const
Definition: Type.h:2567
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4037
This represents one expression.
Definition: Expr.h:108
QualType getPointeeType() const
Definition: Type.h:2771
std::string Label
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
Declaration of a template type parameter.
Will not traverse implicit casts and parentheses.
Definition: ASTTypeTraits.h:46
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5579
void dumpTemplateDecl(const TemplateDecl *D)
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:49
Ignore AST nodes not written in the source.
Definition: ASTTypeTraits.h:49
QualType getBaseType() const
Definition: Type.h:4439
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4091
void Visit(const CXXCtorInitializer *Init)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents the type decltype(expr) (C++11).
Definition: Type.h:4370
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:593
QualType getType() const
Definition: Expr.h:137
A unary type transform, which is a type constructed from another.
Definition: Type.h:4413
void VisitVarTemplateDecl(const VarTemplateDecl *D)
Qualifiers Quals
The local qualifiers.
Definition: Type.h:598
Declaration of an alias template.
void VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
clauselist_range clauselists()
Definition: DeclOpenMP.h:502
void VisitEnumConstantDecl(const EnumConstantDecl *D)
Represents a GCC generic vector type.
Definition: Type.h:3235
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1287
void VisitBindingDecl(const BindingDecl *D)
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Expr * getUnderlyingExpr() const
Definition: Type.h:4309
void SetTraversalKind(ast_type_traits::TraversalKind TK)
void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D)
void VisitDecltypeType(const DecltypeType *T)
bool hasQualifiers() const
Return true if the set contains any qualifiers.
Definition: Type.h:420
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6264
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:747
void VisitReferenceType(const ReferenceType *T)
void VisitClassScopeFunctionSpecializationDecl(const ClassScopeFunctionSpecializationDecl *D)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:1075
This captures a statement into a function.
Definition: Stmt.h:3376
void VisitPipeType(const PipeType *T)
void VisitVarDecl(const VarDecl *D)
void VisitArrayType(const ArrayType *T)
void Visit(const ast_type_traits::DynTypedNode &N)
QualType getReturnType() const
Definition: Type.h:3680
void VisitObjCCategoryDecl(const ObjCCategoryDecl *D)
This represents &#39;#pragma omp declare reduction ...&#39; directive.
Definition: DeclOpenMP.h:102
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:312
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:33
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2344
void VisitDecompositionDecl(const DecompositionDecl *D)
void VisitOpaqueValueExpr(const OpaqueValueExpr *Node)
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3403
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:377
QualType getElementType() const
Definition: Type.h:3270
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1225
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2876
void Visit(const TemplateArgument &A, SourceRange R={}, const Decl *From=nullptr, const char *Label=nullptr)
void VisitDeclStmt(const DeclStmt *Node)
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:855
void VisitLocInfoType(const LocInfoType *T)
void VisitFunctionType(const FunctionType *T)
void VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T)
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
Definition: Type.cpp:354
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2294
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4802
unsigned capture_size() const
Determine the number of captures in this lambda.
Definition: ExprCXX.h:1919
Comment *const * child_iterator
Definition: Comment.h:224
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
ASTNodeTraverser traverses the Clang AST for dumping purposes.
void VisitClassTemplateDecl(const ClassTemplateDecl *D)
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Definition: DeclTemplate.h:362
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3763
void VisitComplexType(const ComplexType *T)
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition: Expr.h:4497
Represents a pack expansion of types.
Definition: Type.h:5511
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:353
Represents a C11 generic selection.
Definition: Expr.h:5234
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:4184
ast_type_traits::DynTypedNode Node
Represents a template argument.
Definition: TemplateBase.h:50
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2662
Dataflow Directional Tag Classes.
void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D)
TypeSourceInfo * getTypeSourceInfo() const
Definition: LocInfoType.h:48
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:498
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
ArrayRef< Capture > captures() const
Definition: Decl.h:4164
void Visit(const Attr *A)
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:402
void VisitAtomicType(const AtomicType *T)
void VisitStaticAssertDecl(const StaticAssertDecl *D)
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1812
attr_range attrs() const
Definition: DeclBase.h:501
void VisitConceptDecl(const ConceptDecl *D)
QualType getUnderlyingType() const
Definition: Decl.h:3126
const Expr * getInit() const
Definition: Decl.h:1229
A decomposition declaration.
Definition: DeclCXX.h:3869
void VisitPointerType(const PointerType *T)
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2833
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
void VisitTypeAliasDecl(const TypeAliasDecl *D)
TemplateParameterList * getTemplateParameterList() const
If this is a generic lambda expression, retrieve the template parameter list associated with it...
Definition: ExprCXX.cpp:1297
void VisitMemberPointerType(const MemberPointerType *T)
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4743
const DefArgStorage & getDefaultArgStorage() const
A dynamically typed AST node container.
QualType getModifiedType() const
Definition: Type.h:4575
Represents a pointer to an Objective C object.
Definition: Type.h:5951
Pointer to a block type.
Definition: Type.h:2716
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2566
void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D)
Complex values, per C99 6.2.5p11.
Definition: Type.h:2554
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:552
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2155
void VisitClassTemplatePartialSpecializationDecl(const ClassTemplatePartialSpecializationDecl *D)
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:516
TraversalKind
Defines how we descend a level in the AST when we pass through expressions.
Definition: ASTTypeTraits.h:40
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2750
decl_range decls()
Definition: Stmt.h:1273
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
void VisitClassTemplateSpecializationDecl(const ClassTemplateSpecializationDecl *D)
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:4179
void Visit(const BlockDecl::Capture &C)
void VisitVarTemplateSpecializationDecl(const VarTemplateSpecializationDecl *D)
A template argument list.
Definition: DeclTemplate.h:239
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1298
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4550
void dumpDeclContext(const DeclContext *DC)
bool isSugared() const
Definition: Type.h:5542
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
The parameter type of a method or function.
Declaration of a class template.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:649
This represents &#39;#pragma omp declare mapper ...&#39; directive.
Definition: DeclOpenMP.h:217
void VisitVectorType(const VectorType *T)
void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T)
varlist_range varlists()
Definition: DeclOpenMP.h:491
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2078
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T)
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1245
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4996
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:4123
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3836
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:97
void VisitLambdaExpr(const LambdaExpr *Node)
varlist_range varlists()
Definition: DeclOpenMP.h:77
QualType getDefaultArgument() const
Retrieve the default argument, if any.
A trivial tuple used to represent a source range.
void VisitDependentSizedArrayType(const DependentSizedArrayType *T)
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3039
void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D)
Expr * getConstraintExpr() const
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:73
bool hasInit() const
Definition: Decl.cpp:2226
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
void VisitUnaryTransformType(const UnaryTransformType *T)
Declaration of a template function.
Definition: DeclTemplate.h:977
Attr - This represents one attribute.
Definition: Attr.h:45
const StringLiteral * getAsmString() const
Definition: Decl.h:4026
QualType getPointeeType() const
Definition: Type.h:2853
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3162
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1093
void VisitTypedefDecl(const TypedefDecl *D)
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6238
association_range associations()
Definition: Expr.h:5463
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:368
void VisitObjCImplementationDecl(const ObjCImplementationDecl *D)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5967