clang 17.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
25#include "clang/AST/Type.h"
27
28namespace clang {
29
30class APValue;
31
32/**
33
34ASTNodeTraverser traverses the Clang AST for dumping purposes.
35
36The `Derived::doGetNodeDelegate()` method is required to be an accessible member
37which returns a reference of type `NodeDelegateType &` which implements the
38following interface:
39
40struct {
41 template <typename Fn> void AddChild(Fn DoAddChild);
42 template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild);
43
44 void Visit(const comments::Comment *C, const comments::FullComment *FC);
45 void Visit(const Attr *A);
46 void Visit(const TemplateArgument &TA, SourceRange R = {},
47 const Decl *From = nullptr, StringRef Label = {});
48 void Visit(const Stmt *Node);
49 void Visit(const Type *T);
50 void Visit(QualType T);
51 void Visit(const Decl *D);
52 void Visit(const CXXCtorInitializer *Init);
53 void Visit(const OMPClause *C);
54 void Visit(const BlockDecl::Capture &C);
55 void Visit(const GenericSelectionExpr::ConstAssociation &A);
56 void Visit(const concepts::Requirement *R);
57 void Visit(const APValue &Value, QualType Ty);
58};
59*/
60template <typename Derived, typename NodeDelegateType>
62 : public ConstDeclVisitor<Derived>,
63 public ConstStmtVisitor<Derived>,
64 public comments::ConstCommentVisitor<Derived, void,
65 const comments::FullComment *>,
66 public TypeVisitor<Derived>,
67 public ConstAttrVisitor<Derived>,
68 public ConstTemplateArgumentVisitor<Derived> {
69
70 /// Indicates whether we should trigger deserialization of nodes that had
71 /// not already been loaded.
72 bool Deserialize = false;
73
75
76 NodeDelegateType &getNodeDelegate() {
77 return getDerived().doGetNodeDelegate();
78 }
79 Derived &getDerived() { return *static_cast<Derived *>(this); }
80
81public:
82 void setDeserialize(bool D) { Deserialize = D; }
83 bool getDeserialize() const { return Deserialize; }
84
87
88 void Visit(const Decl *D) {
90 return;
91
92 getNodeDelegate().AddChild([=] {
93 getNodeDelegate().Visit(D);
94 if (!D)
95 return;
96
98
99 for (const auto &A : D->attrs())
100 Visit(A);
101
102 if (const comments::FullComment *Comment =
104 Visit(Comment, Comment);
105
106 // Decls within functions are visited by the body.
107 if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D)) {
108 if (Traversal != TK_AsIs) {
109 if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
110 auto SK = CTSD->getSpecializationKind();
113 return;
114 }
115 }
116 if (const auto *DC = dyn_cast<DeclContext>(D))
117 dumpDeclContext(DC);
118 }
119 });
120 }
121
122 void Visit(const Stmt *Node, StringRef Label = {}) {
123 getNodeDelegate().AddChild(Label, [=] {
124 const Stmt *S = Node;
125
126 if (auto *E = dyn_cast_or_null<Expr>(S)) {
127 switch (Traversal) {
128 case TK_AsIs:
129 break;
131 S = E->IgnoreUnlessSpelledInSource();
132 break;
133 }
134 }
135
136 getNodeDelegate().Visit(S);
137
138 if (!S) {
139 return;
140 }
141
143
144 // Some statements have custom mechanisms for dumping their children.
145 if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S) ||
146 isa<RequiresExpr>(S))
147 return;
148
149 if (Traversal == TK_IgnoreUnlessSpelledInSource &&
150 isa<LambdaExpr, CXXForRangeStmt, CallExpr,
151 CXXRewrittenBinaryOperator>(S))
152 return;
153
154 for (const Stmt *SubStmt : S->children())
155 Visit(SubStmt);
156 });
157 }
158
159 void Visit(QualType T) {
160 SplitQualType SQT = T.split();
161 if (!SQT.Quals.hasQualifiers())
162 return Visit(SQT.Ty);
163
164 getNodeDelegate().AddChild([=] {
165 getNodeDelegate().Visit(T);
166 Visit(T.split().Ty);
167 });
168 }
169
170 void Visit(const Type *T) {
171 getNodeDelegate().AddChild([=] {
172 getNodeDelegate().Visit(T);
173 if (!T)
174 return;
176
177 QualType SingleStepDesugar =
179 if (SingleStepDesugar != QualType(T, 0))
180 Visit(SingleStepDesugar);
181 });
182 }
183
184 void Visit(const Attr *A) {
185 getNodeDelegate().AddChild([=] {
186 getNodeDelegate().Visit(A);
188 });
189 }
190
191 void Visit(const CXXCtorInitializer *Init) {
192 if (Traversal == TK_IgnoreUnlessSpelledInSource && !Init->isWritten())
193 return;
194 getNodeDelegate().AddChild([=] {
195 getNodeDelegate().Visit(Init);
196 Visit(Init->getInit());
197 });
198 }
199
200 void Visit(const TemplateArgument &A, SourceRange R = {},
201 const Decl *From = nullptr, const char *Label = nullptr) {
202 getNodeDelegate().AddChild([=] {
203 getNodeDelegate().Visit(A, R, From, Label);
205 });
206 }
207
209 getNodeDelegate().AddChild([=] {
210 getNodeDelegate().Visit(C);
211 if (C.hasCopyExpr())
212 Visit(C.getCopyExpr());
213 });
214 }
215
216 void Visit(const OMPClause *C) {
217 getNodeDelegate().AddChild([=] {
218 getNodeDelegate().Visit(C);
219 for (const auto *S : C->children())
220 Visit(S);
221 });
222 }
223
225 getNodeDelegate().AddChild([=] {
226 getNodeDelegate().Visit(A);
227 if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
228 Visit(TSI->getType());
229 Visit(A.getAssociationExpr());
230 });
231 }
232
234 getNodeDelegate().AddChild([=] {
235 getNodeDelegate().Visit(R);
236 if (!R)
237 return;
238 if (auto *TR = dyn_cast<concepts::TypeRequirement>(R)) {
239 if (!TR->isSubstitutionFailure())
240 Visit(TR->getType()->getType().getTypePtr());
241 } else if (auto *ER = dyn_cast<concepts::ExprRequirement>(R)) {
242 if (!ER->isExprSubstitutionFailure())
243 Visit(ER->getExpr());
244 if (!ER->getReturnTypeRequirement().isEmpty())
245 Visit(ER->getReturnTypeRequirement()
246 .getTypeConstraint()
247 ->getImmediatelyDeclaredConstraint());
248 } else if (auto *NR = dyn_cast<concepts::NestedRequirement>(R)) {
249 if (!NR->hasInvalidConstraint())
250 Visit(NR->getConstraintExpr());
251 }
252 });
253 }
254
255 void Visit(const APValue &Value, QualType Ty) {
256 getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); });
257 }
258
260 getNodeDelegate().AddChild([=] {
261 getNodeDelegate().Visit(C, FC);
262 if (!C) {
263 return;
264 }
265 comments::ConstCommentVisitor<Derived, void,
267 FC);
268 for (comments::Comment::child_iterator I = C->child_begin(),
269 E = C->child_end();
270 I != E; ++I)
271 Visit(*I, FC);
272 });
273 }
274
275 void Visit(const DynTypedNode &N) {
276 // FIXME: Improve this with a switch or a visitor pattern.
277 if (const auto *D = N.get<Decl>())
278 Visit(D);
279 else if (const auto *S = N.get<Stmt>())
280 Visit(S);
281 else if (const auto *QT = N.get<QualType>())
282 Visit(*QT);
283 else if (const auto *T = N.get<Type>())
284 Visit(T);
285 else if (const auto *C = N.get<CXXCtorInitializer>())
286 Visit(C);
287 else if (const auto *C = N.get<OMPClause>())
288 Visit(C);
289 else if (const auto *T = N.get<TemplateArgument>())
290 Visit(*T);
291 }
292
293 void dumpDeclContext(const DeclContext *DC) {
294 if (!DC)
295 return;
296
297 for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
298 Visit(D);
299 }
300
302 if (!TPL)
303 return;
304
305 for (const auto &TP : *TPL)
306 Visit(TP);
307
308 if (const Expr *RC = TPL->getRequiresClause())
309 Visit(RC);
310 }
311
312 void
314 if (!TALI)
315 return;
316
317 for (const auto &TA : TALI->arguments())
319 }
320
322 const Decl *From = nullptr,
323 const char *Label = nullptr) {
324 Visit(A.getArgument(), A.getSourceRange(), From, Label);
325 }
326
328 for (unsigned i = 0, e = TAL.size(); i < e; ++i)
329 Visit(TAL[i]);
330 }
331
332 void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams) {
333 if (!typeParams)
334 return;
335
336 for (const auto &typeParam : *typeParams) {
337 Visit(typeParam);
338 }
339 }
340
344 }
347 Visit(T->getPointeeType());
348 }
350 Visit(T->getPointeeType());
351 }
353 Visit(T->getClass());
354 Visit(T->getPointeeType());
355 }
359 Visit(T->getSizeExpr());
360 }
362 Visit(T->getElementType());
363 Visit(T->getSizeExpr());
364 }
366 Visit(T->getElementType());
367 Visit(T->getSizeExpr());
368 }
373 for (const QualType &PT : T->getParamTypes())
374 Visit(PT);
375 }
378 }
381 }
383 Visit(T->getBaseType());
384 }
386 // FIXME: AttrKind
387 if (T->getModifiedType() != T->getEquivalentType())
389 }
391 Visit(T->getWrappedType());
392 }
394 void
397 }
399 for (const auto &Arg : T->template_arguments())
400 Visit(Arg);
401 }
403 Visit(T->getPointeeType());
404 }
406 void VisitPipeType(const PipeType *T) { Visit(T->getElementType()); }
409 if (!T->isSugared())
410 Visit(T->getPattern());
411 }
412 // FIXME: ElaboratedType, DependentNameType,
413 // DependentTemplateSpecializationType, ObjCObjectType
414
416
418 if (const Expr *Init = D->getInitExpr())
419 Visit(Init);
420 }
421
423 if (const auto *FTSI = D->getTemplateSpecializationInfo())
424 dumpTemplateArgumentList(*FTSI->TemplateArguments);
425
426 if (D->param_begin())
427 for (const auto *Parameter : D->parameters())
429
430 if (const Expr *TRC = D->getTrailingRequiresClause())
431 Visit(TRC);
432
434 return;
435
436 if (const auto *C = dyn_cast<CXXConstructorDecl>(D))
437 for (const auto *I : C->inits())
438 Visit(I);
439
441 Visit(D->getBody());
442 }
443
444 void VisitFieldDecl(const FieldDecl *D) {
445 if (D->isBitField())
446 Visit(D->getBitWidth());
447 if (Expr *Init = D->getInClassInitializer())
448 Visit(Init);
449 }
450
451 void VisitVarDecl(const VarDecl *D) {
453 return;
454
455 if (D->hasInit())
456 Visit(D->getInit());
457 }
458
460 VisitVarDecl(D);
461 for (const auto *B : D->bindings())
462 Visit(B);
463 }
464
467 return;
468
469 if (const auto *V = D->getHoldingVar())
470 Visit(V);
471
472 if (const auto *E = D->getBinding())
473 Visit(E);
474 }
475
477 Visit(D->getAsmString());
478 }
479
481
482 void VisitCapturedDecl(const CapturedDecl *D) { Visit(D->getBody()); }
483
485 for (const auto *E : D->varlists())
486 Visit(E);
487 }
488
490 Visit(D->getCombiner());
491 if (const auto *Initializer = D->getInitializer())
493 }
494
496 for (const auto *C : D->clauselists())
497 Visit(C);
498 }
499
501 Visit(D->getInit());
502 }
503
505 for (const auto *E : D->varlists())
506 Visit(E);
507 for (const auto *C : D->clauselists())
508 Visit(C);
509 }
510
511 template <typename SpecializationDecl>
512 void dumpTemplateDeclSpecialization(const SpecializationDecl *D) {
513 for (const auto *RedeclWithBadType : D->redecls()) {
514 // FIXME: The redecls() range sometimes has elements of a less-specific
515 // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
516 // us TagDecls, and should give CXXRecordDecls).
517 auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
518 if (!Redecl) {
519 // Found the injected-class-name for a class template. This will be
520 // dumped as part of its surrounding class so we don't need to dump it
521 // here.
522 assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
523 "expected an injected-class-name");
524 continue;
525 }
526 Visit(Redecl);
527 }
528 }
529
530 template <typename TemplateDecl>
533
535
536 if (Traversal == TK_AsIs) {
537 for (const auto *Child : D->specializations())
539 }
540 }
541
544 }
545
549 }
550
552 Visit(D->getAssertExpr());
553 Visit(D->getMessage());
554 }
555
558 }
559
562 }
563
567 }
568
573 }
574
579 }
581
584 }
585
586 void
589 VisitVarDecl(D);
590 }
591
596 }
597
599 if (const auto *TC = D->getTypeConstraint())
600 Visit(TC->getImmediatelyDeclaredConstraint());
601 if (D->hasDefaultArgument())
604 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
605 }
606
608 if (const auto *E = D->getPlaceholderTypeConstraint())
609 Visit(E);
610 if (D->hasDefaultArgument())
613 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
614 }
615
618 if (D->hasDefaultArgument())
621 D->defaultArgumentWasInherited() ? "inherited from" : "previous");
622 }
623
627 }
628
631 for (const TemplateArgument &Arg : CSD->getTemplateArguments())
632 Visit(Arg);
633 }
634
637 if (CSE->hasExplicitTemplateArgs())
638 for (const auto &ArgLoc : CSE->getTemplateArgsAsWritten()->arguments())
640 }
641
643 if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl()))
644 Visit(TD->getTypeForDecl());
645 }
646
648 if (D->getFriendType()) {
649 // Traverse any CXXRecordDecl owned by this type, since
650 // it will not be in the parent context:
651 if (auto *ET = D->getFriendType()->getType()->getAs<ElaboratedType>())
652 if (auto *TD = ET->getOwnedTagDecl())
653 Visit(TD);
654 } else {
655 Visit(D->getFriendDecl());
656 }
657 }
658
662 else
663 for (const ParmVarDecl *Parameter : D->parameters())
665
666 if (D->hasBody())
667 Visit(D->getBody());
668 }
669
672 }
673
676 }
677
679 for (const auto &I : D->inits())
680 Visit(I);
681 }
682
683 void VisitBlockDecl(const BlockDecl *D) {
684 for (const auto &I : D->parameters())
685 Visit(I);
686
687 for (const auto &I : D->captures())
688 Visit(I);
689 Visit(D->getBody());
690 }
691
693 for (const auto &D : Node->decls())
694 Visit(D);
695 }
696
698 for (const auto *A : Node->getAttrs())
699 Visit(A);
700 }
701
703 Visit(Node->getExceptionDecl());
704 }
705
707 Visit(Node->getCapturedDecl());
708 }
709
711 for (const auto *C : Node->clauses())
712 Visit(C);
713 }
714
716 if (auto *Filler = ILE->getArrayFiller()) {
717 Visit(Filler, "array_filler");
718 }
719 }
720
722 if (auto *Filler = PLIE->getArrayFiller()) {
723 Visit(Filler, "array_filler");
724 }
725 }
726
727 void VisitBlockExpr(const BlockExpr *Node) { Visit(Node->getBlockDecl()); }
728
730 if (Expr *Source = Node->getSourceExpr())
731 Visit(Source);
732 }
733
736 Visit(E->getControllingExpr()->getType()); // FIXME: remove
737
738 for (const auto Assoc : E->associations()) {
739 Visit(Assoc);
740 }
741 }
742
744 for (auto *D : E->getLocalParameters())
745 Visit(D);
746 for (auto *R : E->getRequirements())
747 Visit(R);
748 }
749
752 for (unsigned I = 0, N = Node->capture_size(); I != N; ++I) {
753 const auto *C = Node->capture_begin() + I;
754 if (!C->isExplicit())
755 continue;
756 if (Node->isInitCapture(C))
757 Visit(C->getCapturedVar());
758 else
759 Visit(Node->capture_init_begin()[I]);
760 }
761 dumpTemplateParameters(Node->getTemplateParameterList());
762 for (const auto *P : Node->getCallOperator()->parameters())
763 Visit(P);
764 Visit(Node->getBody());
765 } else {
766 return Visit(Node->getLambdaClass());
767 }
768 }
769
771 if (Node->isPartiallySubstituted())
772 for (const auto &A : Node->getPartialArguments())
773 Visit(A);
774 }
775
777 Visit(E->getParameter());
778 }
783 }
784
786 if (const VarDecl *CatchParam = Node->getCatchParamDecl())
787 Visit(CatchParam);
788 }
789
792 Visit(Node->getInit());
793 Visit(Node->getLoopVariable());
794 Visit(Node->getRangeInit());
795 Visit(Node->getBody());
796 }
797 }
798
800 for (const auto *Child :
801 make_filter_range(Node->children(), [this](const Stmt *Child) {
802 if (Traversal != TK_IgnoreUnlessSpelledInSource)
803 return false;
804 return !isa<CXXDefaultArgExpr>(Child);
805 })) {
806 Visit(Child);
807 }
808 }
809
812 Visit(Node->getLHS());
813 Visit(Node->getRHS());
814 } else {
816 }
817 }
818
820 Visit(TA.getAsExpr());
821 }
822
824 Visit(TA.getAsType());
825 }
826
828 for (const auto &TArg : TA.pack_elements())
829 Visit(TArg);
830 }
831
832 // Implements Visit methods for Attrs.
833#include "clang/AST/AttrNodeTraverse.inc"
834};
835
836} // namespace clang
837
838#endif // LLVM_CLANG_AST_ASTNODETRAVERSER_H
#define V(N, I)
Definition: ASTContext.h:3217
DynTypedNode Node
TraversalKind Traversal
C Language Family Type Representation.
std::string Label
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:629
ASTNodeTraverser traverses the Clang AST for dumping purposes.
void VisitSubstNonTypeTemplateParmPackExpr(const SubstNonTypeTemplateParmPackExpr *E)
void VisitDeclStmt(const DeclStmt *Node)
void VisitFunctionType(const FunctionType *T)
void VisitCapturedDecl(const CapturedDecl *D)
void Visit(const BlockDecl::Capture &C)
void VisitAdjustedType(const AdjustedType *T)
void VisitSizeOfPackExpr(const SizeOfPackExpr *Node)
void VisitMemberPointerType(const MemberPointerType *T)
void VisitDependentSizedArrayType(const DependentSizedArrayType *T)
void VisitTypeOfExprType(const TypeOfExprType *T)
void VisitLocInfoType(const LocInfoType *T)
void dumpTemplateDeclSpecialization(const SpecializationDecl *D)
void Visit(const comments::Comment *C, const comments::FullComment *FC)
void VisitClassTemplateSpecializationDecl(const ClassTemplateSpecializationDecl *D)
void VisitBlockDecl(const BlockDecl *D)
void VisitObjCImplementationDecl(const ObjCImplementationDecl *D)
void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D)
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node)
void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D)
void VisitCXXParenListInitExpr(const CXXParenListInitExpr *PLIE)
void dumpTemplateArgumentList(const TemplateArgumentList &TAL)
void Visit(const OMPClause *C)
void VisitImplicitConceptSpecializationDecl(const ImplicitConceptSpecializationDecl *CSD)
void VisitReferenceType(const ReferenceType *T)
void VisitBlockExpr(const BlockExpr *Node)
void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
void VisitStaticAssertDecl(const StaticAssertDecl *D)
void VisitBlockPointerType(const BlockPointerType *T)
void VisitFieldDecl(const FieldDecl *D)
void VisitAttributedStmt(const AttributedStmt *Node)
void Visit(const Type *T)
void VisitPipeType(const PipeType *T)
void Visit(const Attr *A)
void VisitClassScopeFunctionSpecializationDecl(const ClassScopeFunctionSpecializationDecl *D)
void VisitInitListExpr(const InitListExpr *ILE)
void VisitVarTemplateDecl(const VarTemplateDecl *D)
void VisitPackExpansionType(const PackExpansionType *T)
void VisitBTFTagAttributedType(const BTFTagAttributedType *T)
void VisitTypeAliasDecl(const TypeAliasDecl *D)
void VisitDecompositionDecl(const DecompositionDecl *D)
void VisitObjCMethodDecl(const ObjCMethodDecl *D)
void VisitClassTemplateDecl(const ClassTemplateDecl *D)
void SetTraversalKind(TraversalKind TK)
void Visit(const concepts::Requirement *R)
void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D)
void VisitComplexType(const ComplexType *T)
void dumpDeclContext(const DeclContext *DC)
void VisitUsingShadowDecl(const UsingShadowDecl *D)
void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams)
void VisitVarTemplateSpecializationDecl(const VarTemplateSpecializationDecl *D)
void Visit(const DynTypedNode &N)
void VisitExpressionTemplateArgument(const TemplateArgument &TA)
void dumpTemplateDecl(const TemplateDecl *D)
void VisitVectorType(const VectorType *T)
void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A, const Decl *From=nullptr, const char *Label=nullptr)
void VisitCXXCatchStmt(const CXXCatchStmt *Node)
void VisitClassTemplatePartialSpecializationDecl(const ClassTemplatePartialSpecializationDecl *D)
void VisitTypedefDecl(const TypedefDecl *D)
void VisitBindingDecl(const BindingDecl *D)
void Visit(const APValue &Value, QualType Ty)
void VisitRequiresExpr(const RequiresExpr *E)
void VisitGenericSelectionExpr(const GenericSelectionExpr *E)
void VisitSubstTemplateTypeParmPackType(const SubstTemplateTypeParmPackType *T)
void VisitOpaqueValueExpr(const OpaqueValueExpr *Node)
void VisitArrayType(const ArrayType *T)
void Visit(const CXXCtorInitializer *Init)
void VisitVarDecl(const VarDecl *D)
void VisitVarTemplatePartialSpecializationDecl(const VarTemplatePartialSpecializationDecl *D)
void VisitFileScopeAsmDecl(const FileScopeAsmDecl *D)
void VisitFunctionProtoType(const FunctionProtoType *T)
void VisitUnaryTransformType(const UnaryTransformType *T)
void VisitLambdaExpr(const LambdaExpr *Node)
void VisitCallExpr(const CallExpr *Node)
void VisitDecltypeType(const DecltypeType *T)
void VisitOMPExecutableDirective(const OMPExecutableDirective *Node)
void VisitEnumConstantDecl(const EnumConstantDecl *D)
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
void VisitAtomicType(const AtomicType *T)
void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T)
void Visit(const Stmt *Node, StringRef Label={})
void Visit(const GenericSelectionExpr::ConstAssociation &A)
void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D)
void VisitConceptDecl(const ConceptDecl *D)
void VisitTopLevelStmtDecl(const TopLevelStmtDecl *D)
void dumpASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *TALI)
void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *CSE)
void VisitVariableArrayType(const VariableArrayType *T)
void VisitTypeTemplateArgument(const TemplateArgument &TA)
void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D)
void VisitOMPAllocateDecl(const OMPAllocateDecl *D)
void VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
void VisitCapturedStmt(const CapturedStmt *Node)
void VisitFriendDecl(const FriendDecl *D)
void VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D)
void VisitCXXForRangeStmt(const CXXForRangeStmt *Node)
void VisitOMPDeclareMapperDecl(const OMPDeclareMapperDecl *D)
void VisitObjCObjectPointerType(const ObjCObjectPointerType *T)
void Visit(const Decl *D)
void VisitAttributedType(const AttributedType *T)
void Visit(const TemplateArgument &A, SourceRange R={}, const Decl *From=nullptr, const char *Label=nullptr)
void VisitPackTemplateArgument(const TemplateArgument &TA)
TraversalKind GetTraversalKind() const
void VisitObjCCategoryDecl(const ObjCCategoryDecl *D)
void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *)
void VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *Node)
void dumpTemplateParameters(const TemplateParameterList *TPL)
void VisitFunctionDecl(const FunctionDecl *D)
void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)
void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D)
void VisitPointerType(const PointerType *T)
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Definition: Type.h:2817
QualType getOriginalType() const
Definition: Type.h:2830
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:3031
QualType getElementType() const
Definition: Type.h:3052
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:6478
Attr - This represents one attribute.
Definition: Attr.h:40
Represents an attribute applied to a statement.
Definition: Stmt.h:1892
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4890
QualType getModifiedType() const
Definition: Type.h:4912
QualType getEquivalentType() const
Definition: Type.h:4913
QualType getWrappedType() const
Definition: Type.h:5002
A binding in a decomposition declaration.
Definition: DeclCXX.h:4039
VarDecl * getHoldingVar() const
Get the variable (if any) that holds the value of evaluating the binding.
Definition: DeclCXX.cpp:3273
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition: DeclCXX.h:4063
A class which contains all the information about a particular captured value.
Definition: Decl.h:4340
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4334
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:4413
ArrayRef< Capture > captures() const
Definition: Decl.h:4461
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:4420
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5975
Pointer to a block type.
Definition: Type.h:2868
QualType getPointeeType() const
Definition: Type.h:2880
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2238
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition: StmtCXX.h:134
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4796
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:283
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2812
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4526
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:5135
This captures a statement into a function.
Definition: Stmt.h:3544
Declaration of a function specialization at template class scope.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Declaration of a class template.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
Complex values, per C99 6.2.5p11.
Definition: Type.h:2735
QualType getElementType() const
Definition: Type.h:2745
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
bool hasExplicitTemplateArgs() const
Whether or not template arguments were explicitly specified in the concept reference (they might not ...
Definition: ASTConcept.h:175
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Definition: ASTConcept.h:169
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Definition: ExprConcepts.h:41
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
Definition: ExprConcepts.h:92
A simple visitor class that helps create attribute visitors.
Definition: AttrVisitor.h:71
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:74
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:194
A simple visitor class that helps create template argument visitors.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1393
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:2196
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2188
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1311
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:428
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
attr_range attrs() const
Definition: DeclBase.h:519
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:841
Represents the type decltype(expr) (C++11).
Definition: Type.h:4709
Expr * getUnderlyingExpr() const
Definition: Type.h:4719
A decomposition declaration.
Definition: DeclCXX.h:4098
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:4130
const ParmDecl * getInheritedFrom() const
Get the parameter from which we inherit the default argument, if any.
Definition: DeclTemplate.h:359
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:3235
Expr * getSizeExpr() const
Definition: Type.h:3257
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3337
QualType getElementType() const
Definition: Type.h:3353
A dynamically typed AST node container.
const T * get() const
Retrieve the stored node as type T.
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:5659
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3160
const Expr * getInitExpr() const
Definition: Decl.h:3179
This represents one expression.
Definition: Expr.h:110
QualType getType() const
Definition: Expr.h:142
Represents a member of a struct/union/class.
Definition: Decl.h:2941
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:3019
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition: Decl.h:3092
Expr * getBitWidth() const
Definition: Decl.h:3030
const StringLiteral * getAsmString() const
Definition: Decl.h:4295
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:54
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:136
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:121
Represents a function declaration or definition.
Definition: Decl.h:1917
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3134
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2582
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3949
param_iterator param_begin()
Definition: Decl.h:2594
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2228
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2280
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4041
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:4253
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3694
QualType getReturnType() const
Definition: Type.h:3959
Represents a C11 generic selection.
Definition: Expr.h:5636
association_range associations()
Definition: Expr.h:5860
AssociationTy< true > ConstAssociation
Definition: Expr.h:5791
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
Definition: Expr.h:5814
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes an C or C++ initializer list.
Definition: Expr.h:4800
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition: Expr.h:4894
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1924
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:28
TypeSourceInfo * getTypeSourceInfo() const
Definition: LocInfoType.h:45
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2979
QualType getPointeeType() const
Definition: Type.h:2995
const Type * getClass() const
Definition: Type.h:3009
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:457
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
const DefArgStorage & getDefaultArgStorage() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:473
varlist_range varlists()
Definition: DeclOpenMP.h:515
clauselist_range clauselists()
Definition: DeclOpenMP.h:526
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:383
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:55
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
clauselist_range clauselists()
Definition: DeclOpenMP.h:333
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:171
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition: DeclOpenMP.h:239
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition: DeclOpenMP.h:221
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
varlist_range varlists()
Definition: DeclOpenMP.h:146
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:77
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2312
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2362
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2584
Represents an ObjC class declaration.
Definition: DeclObjC.h:1147
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
Definition: DeclObjC.h:1292
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:524
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:375
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:909
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:535
Represents a pointer to an Objective C object.
Definition: Type.h:6297
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:6309
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:658
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1146
Represents a pack expansion of types.
Definition: Type.h:5858
bool isSugared() const
Definition: Type.h:5889
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5879
Represents a parameter to a function.
Definition: Decl.h:1722
PipeType - OpenCL20.
Definition: Type.h:6497
QualType getElementType() const
Definition: Type.h:6508
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2788
QualType getPointeeType() const
Definition: Type.h:2798
A (possibly-)qualified type.
Definition: Type.h:736
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:6670
bool hasQualifiers() const
Return true if the set contains any qualifiers.
Definition: Type.h:438
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2899
QualType getPointeeType() const
Definition: Type.h:2917
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:478
ArrayRef< concepts::Requirement * > getRequirements() const
Definition: ExprConcepts.h:519
ArrayRef< ParmVarDecl * > getLocalParameters() const
Definition: ExprConcepts.h:513
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4202
A trivial tuple used to represent a source range.
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3990
StringLiteral * getMessage()
Definition: DeclCXX.h:4016
RetTy Visit(PTR(Stmt) S, ParamTys... P)
Definition: StmtVisitor.h:43
Stmt - This represents one statement.
Definition: Stmt.h:72
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4318
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.cpp:1643
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4403
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Definition: ExprCXX.cpp:1674
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
Definition: ExprCXX.cpp:1669
Represents the result of substituting a set of types for a template type parameter pack.
Definition: Type.h:5175
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3775
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:5105
A template argument list.
Definition: DeclTemplate.h:238
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:296
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:484
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:533
SourceRange getSourceRange() const LLVM_READONLY
Represents a template argument.
Definition: TemplateBase.h:60
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:368
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:287
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:392
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:407
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:439
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:426
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:174
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:5377
ArrayRef< TemplateArgument > template_arguments() const
Definition: Type.h:5445
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
const DefArgStorage & getDefaultArgStorage() const
const TemplateArgumentLoc & 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.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
QualType getDefaultArgument() const
Retrieve the default argument, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
const DefArgStorage & getDefaultArgStorage() const
A declaration that models statements at global scope.
Definition: Decl.h:4308
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3412
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a typeof (or typeof) expression (a C2x feature and GCC extension) or a typeof_unqual expre...
Definition: Type.h:4622
Expr * getUnderlyingExpr() const
Definition: Type.h:4631
A container of type source information.
Definition: Type.h:6620
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6631
An operation on a type.
Definition: TypeVisitor.h:64
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:68
The base class of the type hierarchy.
Definition: Type.h:1566
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
Definition: Type.cpp:422
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7424
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3392
QualType getUnderlyingType() const
Definition: Decl.h:3345
A unary type transform, which is a type constructed from another.
Definition: Type.h:4752
QualType getBaseType() const
Definition: Type.h:4779
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3253
Represents a variable declaration or definition.
Definition: Decl.h:913
bool hasInit() const
Definition: Decl.cpp:2343
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition: Decl.h:1472
const Expr * getInit() const
Definition: Decl.h:1325
Declaration of a variable template.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a variable template specialization, which refers to a variable template with a given set o...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:3181
Expr * getSizeExpr() const
Definition: Type.h:3200
Represents a GCC generic vector type.
Definition: Type.h:3377
QualType getElementType() const
Definition: Type.h:3418
RetTy Visit(PTR(Attr) A)
Definition: AttrVisitor.h:31
RetTy visit(PTR(Comment) C, ParamTys... P)
Any part of the comment.
Definition: Comment.h:52
Comment *const * child_iterator
Definition: Comment.h:227
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1077
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:146
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
RetTy Visit(REF(TemplateArgument) TA, ParamTys... P)
TraversalKind
Defines how we descend a level in the AST when we pass through expressions.
Definition: ASTTypeTraits.h:38
@ TK_AsIs
Will traverse all child nodes.
Definition: ASTTypeTraits.h:40
@ TK_IgnoreUnlessSpelledInSource
Ignore AST nodes not written in the source.
Definition: ASTTypeTraits.h:43
@ C
Languages that the frontend can parse and compile.
@ Parameter
The parameter type of a method or function.
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:194
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:190
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:641
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:670
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:669
const Type * Ty
The locally-unqualified type.
Definition: Type.h:671
Qualifiers Quals
The local qualifiers.
Definition: Type.h:674