clang  9.0.0svn
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 
68  NodeDelegateType &getNodeDelegate() {
69  return getDerived().doGetNodeDelegate();
70  }
71  Derived &getDerived() { return *static_cast<Derived *>(this); }
72 
73 public:
74  void setDeserialize(bool D) { Deserialize = D; }
75  bool getDeserialize() const { return Deserialize; }
76 
77  void Visit(const Decl *D) {
78  getNodeDelegate().AddChild([=] {
79  getNodeDelegate().Visit(D);
80  if (!D)
81  return;
82 
84 
85  for (const auto &A : D->attrs())
86  Visit(A);
87 
88  if (const comments::FullComment *Comment =
90  Visit(Comment, Comment);
91 
92  // Decls within functions are visited by the body.
93  if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D)) {
94  if (const auto *DC = dyn_cast<DeclContext>(D))
95  dumpDeclContext(DC);
96  }
97  });
98  }
99 
100  void Visit(const Stmt *S, StringRef Label = {}) {
101  getNodeDelegate().AddChild(Label, [=] {
102  getNodeDelegate().Visit(S);
103 
104  if (!S) {
105  return;
106  }
107 
109 
110  // Some statements have custom mechanisms for dumping their children.
111  if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S)) {
112  return;
113  }
114 
115  for (const Stmt *SubStmt : S->children())
116  Visit(SubStmt);
117  });
118  }
119 
120  void Visit(QualType T) {
121  SplitQualType SQT = T.split();
122  if (!SQT.Quals.hasQualifiers())
123  return Visit(SQT.Ty);
124 
125  getNodeDelegate().AddChild([=] {
126  getNodeDelegate().Visit(T);
127  Visit(T.split().Ty);
128  });
129  }
130 
131  void Visit(const Type *T) {
132  getNodeDelegate().AddChild([=] {
133  getNodeDelegate().Visit(T);
134  if (!T)
135  return;
137 
138  QualType SingleStepDesugar =
140  if (SingleStepDesugar != QualType(T, 0))
141  Visit(SingleStepDesugar);
142  });
143  }
144 
145  void Visit(const Attr *A) {
146  getNodeDelegate().AddChild([=] {
147  getNodeDelegate().Visit(A);
149  });
150  }
151 
152  void Visit(const CXXCtorInitializer *Init) {
153  getNodeDelegate().AddChild([=] {
154  getNodeDelegate().Visit(Init);
155  Visit(Init->getInit());
156  });
157  }
158 
159  void Visit(const TemplateArgument &A, SourceRange R = {},
160  const Decl *From = nullptr, const char *Label = nullptr) {
161  getNodeDelegate().AddChild([=] {
162  getNodeDelegate().Visit(A, R, From, Label);
164  });
165  }
166 
167  void Visit(const BlockDecl::Capture &C) {
168  getNodeDelegate().AddChild([=] {
169  getNodeDelegate().Visit(C);
170  if (C.hasCopyExpr())
171  Visit(C.getCopyExpr());
172  });
173  }
174 
175  void Visit(const OMPClause *C) {
176  getNodeDelegate().AddChild([=] {
177  getNodeDelegate().Visit(C);
178  for (const auto *S : C->children())
179  Visit(S);
180  });
181  }
182 
184  getNodeDelegate().AddChild([=] {
185  getNodeDelegate().Visit(A);
186  if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
187  Visit(TSI->getType());
188  Visit(A.getAssociationExpr());
189  });
190  }
191 
192  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
193  getNodeDelegate().AddChild([=] {
194  getNodeDelegate().Visit(C, FC);
195  if (!C) {
196  return;
197  }
198  comments::ConstCommentVisitor<Derived, void,
199  const comments::FullComment *>::visit(C,
200  FC);
202  E = C->child_end();
203  I != E; ++I)
204  Visit(*I, FC);
205  });
206  }
207 
209  // FIXME: Improve this with a switch or a visitor pattern.
210  if (const auto *D = N.get<Decl>())
211  Visit(D);
212  else if (const auto *S = N.get<Stmt>())
213  Visit(S);
214  else if (const auto *QT = N.get<QualType>())
215  Visit(*QT);
216  else if (const auto *T = N.get<Type>())
217  Visit(T);
218  else if (const auto *C = N.get<CXXCtorInitializer>())
219  Visit(C);
220  else if (const auto *C = N.get<OMPClause>())
221  Visit(C);
222  else if (const auto *T = N.get<TemplateArgument>())
223  Visit(*T);
224  }
225 
226  void dumpDeclContext(const DeclContext *DC) {
227  if (!DC)
228  return;
229 
230  for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
231  Visit(D);
232  }
233 
235  if (!TPL)
236  return;
237 
238  for (const auto &TP : *TPL)
239  Visit(TP);
240  }
241 
242  void
244  if (!TALI)
245  return;
246 
247  for (const auto &TA : TALI->arguments())
249  }
250 
252  const Decl *From = nullptr,
253  const char *Label = nullptr) {
254  Visit(A.getArgument(), A.getSourceRange(), From, Label);
255  }
256 
258  for (unsigned i = 0, e = TAL.size(); i < e; ++i)
259  Visit(TAL[i]);
260  }
261 
262  void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams) {
263  if (!typeParams)
264  return;
265 
266  for (const auto &typeParam : *typeParams) {
267  Visit(typeParam);
268  }
269  }
270 
272  void VisitLocInfoType(const LocInfoType *T) {
274  }
277  Visit(T->getPointeeType());
278  }
280  Visit(T->getPointeeType());
281  }
283  Visit(T->getClass());
284  Visit(T->getPointeeType());
285  }
286  void VisitArrayType(const ArrayType *T) { Visit(T->getElementType()); }
288  VisitArrayType(T);
289  Visit(T->getSizeExpr());
290  }
292  Visit(T->getElementType());
293  Visit(T->getSizeExpr());
294  }
296  Visit(T->getElementType());
297  Visit(T->getSizeExpr());
298  }
299  void VisitVectorType(const VectorType *T) { Visit(T->getElementType()); }
303  for (const QualType &PT : T->getParamTypes())
304  Visit(PT);
305  }
307  Visit(T->getUnderlyingExpr());
308  }
310  Visit(T->getUnderlyingExpr());
311  }
313  Visit(T->getBaseType());
314  }
316  // FIXME: AttrKind
317  Visit(T->getModifiedType());
318  }
321  }
322  void
325  Visit(T->getArgumentPack());
326  }
328  for (const auto &Arg : *T)
329  Visit(Arg);
330  if (T->isTypeAlias())
331  Visit(T->getAliasedType());
332  }
334  Visit(T->getPointeeType());
335  }
336  void VisitAtomicType(const AtomicType *T) { Visit(T->getValueType()); }
337  void VisitPipeType(const PipeType *T) { Visit(T->getElementType()); }
340  if (!T->isSugared())
341  Visit(T->getPattern());
342  }
343  // FIXME: ElaboratedType, DependentNameType,
344  // DependentTemplateSpecializationType, ObjCObjectType
345 
347 
349  if (const Expr *Init = D->getInitExpr())
350  Visit(Init);
351  }
352 
354  if (const auto *FTSI = D->getTemplateSpecializationInfo())
355  dumpTemplateArgumentList(*FTSI->TemplateArguments);
356 
357  if (D->param_begin())
358  for (const auto *Parameter : D->parameters())
359  Visit(Parameter);
360 
361  if (const auto *C = dyn_cast<CXXConstructorDecl>(D))
362  for (const auto *I : C->inits())
363  Visit(I);
364 
366  Visit(D->getBody());
367  }
368 
369  void VisitFieldDecl(const FieldDecl *D) {
370  if (D->isBitField())
371  Visit(D->getBitWidth());
372  if (Expr *Init = D->getInClassInitializer())
373  Visit(Init);
374  }
375 
376  void VisitVarDecl(const VarDecl *D) {
377  if (D->hasInit())
378  Visit(D->getInit());
379  }
380 
382  VisitVarDecl(D);
383  for (const auto *B : D->bindings())
384  Visit(B);
385  }
386 
387  void VisitBindingDecl(const BindingDecl *D) {
388  if (const auto *E = D->getBinding())
389  Visit(E);
390  }
391 
393  Visit(D->getAsmString());
394  }
395 
396  void VisitCapturedDecl(const CapturedDecl *D) { Visit(D->getBody()); }
397 
399  for (const auto *E : D->varlists())
400  Visit(E);
401  }
402 
404  Visit(D->getCombiner());
405  if (const auto *Initializer = D->getInitializer())
407  }
408 
410  for (const auto *C : D->clauselists())
411  Visit(C);
412  }
413 
415  Visit(D->getInit());
416  }
417 
419  for (const auto *E : D->varlists())
420  Visit(E);
421  for (const auto *C : D->clauselists())
422  Visit(C);
423  }
424 
425  template <typename SpecializationDecl>
426  void dumpTemplateDeclSpecialization(const SpecializationDecl *D) {
427  for (const auto *RedeclWithBadType : D->redecls()) {
428  // FIXME: The redecls() range sometimes has elements of a less-specific
429  // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
430  // us TagDecls, and should give CXXRecordDecls).
431  auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
432  if (!Redecl) {
433  // Found the injected-class-name for a class template. This will be
434  // dumped as part of its surrounding class so we don't need to dump it
435  // here.
436  assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
437  "expected an injected-class-name");
438  continue;
439  }
440  Visit(Redecl);
441  }
442  }
443 
444  template <typename TemplateDecl>
447 
448  Visit(D->getTemplatedDecl());
449 
450  for (const auto *Child : D->specializations())
452  }
453 
455  Visit(D->getUnderlyingType());
456  }
457 
460  Visit(D->getTemplatedDecl());
461  }
462 
464  Visit(D->getAssertExpr());
465  Visit(D->getMessage());
466  }
467 
469  dumpTemplateDecl(D);
470  }
471 
473  dumpTemplateDecl(D);
474  }
475 
479  }
480 
485  }
486 
489  Visit(D->getSpecialization());
491  }
493 
496  }
497 
498  void
501  VisitVarDecl(D);
502  }
503 
508  }
509 
511  if (D->hasDefaultArgument())
514  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
515  }
516 
518  if (D->hasDefaultArgument())
521  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
522  }
523 
526  if (D->hasDefaultArgument())
529  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
530  }
531 
533  if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl()))
534  Visit(TD->getTypeForDecl());
535  }
536 
537  void VisitFriendDecl(const FriendDecl *D) {
538  if (!D->getFriendType())
539  Visit(D->getFriendDecl());
540  }
541 
544  dumpDeclContext(D);
545  else
546  for (const ParmVarDecl *Parameter : D->parameters())
547  Visit(Parameter);
548 
549  if (D->hasBody())
550  Visit(D->getBody());
551  }
552 
555  }
556 
559  }
560 
562  for (const auto &I : D->inits())
563  Visit(I);
564  }
565 
566  void VisitBlockDecl(const BlockDecl *D) {
567  for (const auto &I : D->parameters())
568  Visit(I);
569 
570  for (const auto &I : D->captures())
571  Visit(I);
572  Visit(D->getBody());
573  }
574 
575  void VisitDeclStmt(const DeclStmt *Node) {
576  for (const auto &D : Node->decls())
577  Visit(D);
578  }
579 
581  for (const auto *A : Node->getAttrs())
582  Visit(A);
583  }
584 
586  Visit(Node->getExceptionDecl());
587  }
588 
590  Visit(Node->getCapturedDecl());
591  }
592 
594  for (const auto *C : Node->clauses())
595  Visit(C);
596  }
597 
598  void VisitInitListExpr(const InitListExpr *ILE) {
599  if (auto *Filler = ILE->getArrayFiller()) {
600  Visit(Filler, "array_filler");
601  }
602  }
603 
604  void VisitBlockExpr(const BlockExpr *Node) { Visit(Node->getBlockDecl()); }
605 
607  if (Expr *Source = Node->getSourceExpr())
608  Visit(Source);
609  }
610 
613  Visit(E->getControllingExpr()->getType()); // FIXME: remove
614 
615  for (const auto &Assoc : E->associations()) {
616  Visit(Assoc);
617  }
618  }
619 
621  Visit(Node->getLambdaClass());
622  }
623 
625  if (Node->isPartiallySubstituted())
626  for (const auto &A : Node->getPartialArguments())
627  Visit(A);
628  }
629 
631  if (const VarDecl *CatchParam = Node->getCatchParamDecl())
632  Visit(CatchParam);
633  }
634 
636  Visit(TA.getAsExpr());
637  }
639  for (const auto &TArg : TA.pack_elements())
640  Visit(TArg);
641  }
642 
643  // Implements Visit methods for Attrs.
644 #include "clang/AST/AttrNodeTraverse.inc"
645 };
646 
647 } // namespace clang
648 
649 #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:5425
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5482
bool hasCopyExpr() const
Definition: Decl.h:3908
const Type * Ty
The locally-unqualified type.
Definition: Type.h:580
Represents a function declaration or definition.
Definition: Decl.h:1743
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2533
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:514
void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)
Expr * getCopyExpr() const
Definition: Decl.h:3909
A class which contains all the information about a particular captured value.
Definition: Decl.h:3869
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2549
QualType getElementType() const
Definition: Type.h:6065
QualType getPointeeType() const
Definition: Type.h:2562
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D)
void VisitAttributedStmt(const AttributedStmt *Node)
A (possibly-)qualified type.
Definition: Type.h:639
void dumpTemplateParameters(const TemplateParameterList *TPL)
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:267
void VisitBlockPointerType(const BlockPointerType *T)
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:192
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:5306
Expr * getUnderlyingExpr() const
Definition: Type.h:4303
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node)
void VisitOMPDeclareMapperDecl(const OMPDeclareMapperDecl *D)
Stmt - This represents one statement.
Definition: Stmt.h:65
Expr * getBitWidth() const
Definition: Decl.h:2673
This represents &#39;#pragma omp allocate ...&#39; directive.
Definition: DeclOpenMP.h:422
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3367
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2791
void VisitAttributedType(const AttributedType *T)
Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier.
Definition: Decl.h:3023
void VisitFunctionDecl(const FunctionDecl *D)
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:274
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:457
void VisitExpressionTemplateArgument(const TemplateArgument &TA)
Represents an attribute applied to a statement.
Definition: Stmt.h:1707
The base class of the type hierarchy.
Definition: Type.h:1414
const DefArgStorage & getDefaultArgStorage() const
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2824
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:68
A container of type source information.
Definition: Decl.h:86
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6032
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
child_iterator child_begin() const
Definition: Comment.cpp:67
void Visit(const comments::Comment *C, const comments::FullComment *FC)
void dumpASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *TALI)
QualType getElementType() const
Definition: Type.h:2859
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:812
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:2019
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:431
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:67
void Visit(const Decl *D)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:631
Represents a parameter to a function.
Definition: Decl.h:1559
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4650
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:1199
PipeType - OpenCL20.
Definition: Type.h:6051
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void VisitObjCMethodDecl(const ObjCMethodDecl *D)
QualType getOriginalType() const
Definition: Type.h:2613
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:3898
QualType getPointeeType() const
Definition: Type.h:2666
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:3907
void VisitGenericSelectionExpr(const GenericSelectionExpr *E)
const DefArgStorage & getDefaultArgStorage() const
Represents a member of a struct/union/class.
Definition: Decl.h:2584
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
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:1310
Represents the result of substituting a set of types for a template type parameter pack...
Definition: Type.h:4706
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1043
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:3942
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:2276
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:4298
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:4565
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:4012
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:170
AssociationTy< true > ConstAssociation
Definition: Expr.h:5283
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2662
void VisitTypeOfExprType(const TypeOfExprType *T)
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2787
void VisitPackExpansionType(const PackExpansionType *T)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
A simple visitor class that helps create template argument visitors.
child_range children()
Definition: Stmt.cpp:212
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:4223
void VisitUsingShadowDecl(const UsingShadowDecl *D)
const Type * getClass() const
Definition: Type.h:2802
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:3524
Expr * getSizeExpr() const
Definition: Type.h:3003
void Visit(const Type *T)
void VisitCapturedDecl(const CapturedDecl *D)
const Expr * getInitExpr() const
Definition: Decl.h:2810
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:1722
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4056
Represents an ObjC class declaration.
Definition: DeclObjC.h:1171
void VisitCapturedStmt(const CapturedStmt *Node)
A binding in a decomposition declaration.
Definition: DeclCXX.h:3921
Expr * getSizeExpr() const
Definition: Type.h:3060
void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams)
void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A, const Decl *From=nullptr, const char *Label=nullptr)
QualType getElementType() const
Definition: Type.h:3156
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3140
param_iterator param_begin()
Definition: Decl.h:2288
void VisitInitListExpr(const InitListExpr *ILE)
child_range children()
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3043
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3699
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:81
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:2027
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:3038
void Visit(const Stmt *S, StringRef Label={})
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:436
QualType getElementType() const
Definition: Type.h:2502
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3863
This represents one expression.
Definition: Expr.h:108
QualType getPointeeType() const
Definition: Type.h:2706
std::string Label
Declaration of a template type parameter.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5468
void dumpTemplateDecl(const TemplateDecl *D)
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:49
QualType getBaseType() const
Definition: Type.h:4362
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3992
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:4293
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:578
QualType getType() const
Definition: Expr.h:137
A unary type transform, which is a type constructed from another.
Definition: Type.h:4336
void VisitVarTemplateDecl(const VarTemplateDecl *D)
Qualifiers Quals
The local qualifiers.
Definition: Type.h:583
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:3180
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
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:4232
void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D)
void VisitDecltypeType(const DecltypeType *T)
bool hasQualifiers() const
Return true if the set contains any qualifiers.
Definition: Type.h:414
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6129
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:985
This captures a statement into a function.
Definition: Stmt.h:3255
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:3625
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:32
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2329
void VisitDecompositionDecl(const DecompositionDecl *D)
void VisitOpaqueValueExpr(const OpaqueValueExpr *Node)
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3374
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:376
QualType getElementType() const
Definition: Type.h:3215
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:1171
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2726
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:851
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:302
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2279
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:50
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4724
Comment *const * child_iterator
Definition: Comment.h:223
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:337
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3872
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:4392
Represents a pack expansion of types.
Definition: Type.h:5404
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:5123
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:4085
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:2597
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:3990
void Visit(const Attr *A)
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:403
void VisitAtomicType(const AtomicType *T)
void VisitStaticAssertDecl(const StaticAssertDecl *D)
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1743
attr_range attrs() const
Definition: DeclBase.h:501
QualType getUnderlyingType() const
Definition: Decl.h:2976
const Expr * getInit() const
Definition: Decl.h:1219
A decomposition declaration.
Definition: DeclCXX.h:3978
void VisitPointerType(const PointerType *T)
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2768
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)
void VisitMemberPointerType(const MemberPointerType *T)
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4665
const DefArgStorage & getDefaultArgStorage() const
A dynamically typed AST node container.
QualType getModifiedType() const
Definition: Type.h:4497
Represents a pointer to an Objective C object.
Definition: Type.h:5843
Pointer to a block type.
Definition: Type.h:2651
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2551
void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D)
Complex values, per C99 6.2.5p11.
Definition: Type.h:2489
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:477
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2335
void VisitClassTemplatePartialSpecializationDecl(const ClassTemplatePartialSpecializationDecl *D)
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:503
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2685
decl_range decls()
Definition: Stmt.h:1219
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:4080
void Visit(const BlockDecl::Capture &C)
void VisitVarTemplateSpecializationDecl(const VarTemplateSpecializationDecl *D)
A template argument list.
Definition: DeclTemplate.h:214
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1261
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4472
void dumpDeclContext(const DeclContext *DC)
bool isSugared() const
Definition: Type.h:5435
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:636
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:2003
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T)
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4890
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3949
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:3945
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:2983
void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D)
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:73
bool hasInit() const
Definition: Decl.cpp:2198
This represents &#39;#pragma omp threadprivate ...&#39; directive.
Definition: DeclOpenMP.h:39
void VisitUnaryTransformType(const UnaryTransformType *T)
Declaration of a template function.
Attr - This represents one attribute.
Definition: Attr.h:43
const StringLiteral * getAsmString() const
Definition: Decl.h:3852
QualType getPointeeType() const
Definition: Type.h:2788
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3265
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1091
void VisitTypedefDecl(const TypedefDecl *D)
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
association_range associations()
Definition: Expr.h:5352
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:366
void VisitObjCImplementationDecl(const ObjCImplementationDecl *D)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5859