Go to the documentation of this file.
13 #ifndef LLVM_CLANG_AST_TEXTNODEDUMPER_H
14 #define LLVM_CLANG_AST_TEXTNODEDUMPER_H
35 const bool ShowColors;
44 bool FirstChild =
true;
51 template <
typename Fn>
void AddChild(Fn DoAddChild) {
63 while (!Pending.empty()) {
73 auto DumpWithIndent = [
this, DoAddChild,
90 OS << Prefix << (IsLastChild ?
'`' :
'|') <<
'-';
94 this->Prefix.push_back(IsLastChild ?
' ' :
'|');
95 this->Prefix.push_back(
' ');
99 unsigned Depth = Pending.size();
105 while (
Depth < Pending.size()) {
106 Pending.back()(
true);
107 this->Pending.pop_back();
111 this->Prefix.resize(Prefix.size() - 2);
115 Pending.push_back(std::move(DumpWithIndent));
117 Pending.back()(
false);
118 Pending.back() = std::move(DumpWithIndent);
124 : OS(OS), ShowColors(ShowColors) {}
130 const comments::FullComment *>,
137 const bool ShowColors;
141 const char *LastLocFilename =
"";
142 unsigned LastLocLine = ~0
U;
156 const char *getCommandName(
unsigned CommandID);
162 unsigned NumChildren, StringRef LabelSingular,
163 StringRef LabelPlurial);
174 const Decl *From =
nullptr, StringRef
Label = {});
231 #include "clang/AST/AttrTextNodeDump.inc"
387 #endif // LLVM_CLANG_AST_TEXTNODEDUMPER_H
void VisitConceptDecl(const ConceptDecl *D)
LabelStmt - Represents a label, which has a substatement.
An expression trait intrinsic.
Represents an ObjC class declaration.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
CaseStmt - Represent a case statement.
ObjCCompatibleAliasDecl - Represents alias of a class.
Represents an access specifier followed by colon ':'.
void VisitClassTemplateDecl(const ClassTemplateDecl *D)
Represents a C++17 deduced template specialization type.
void VisitObjCMessageExpr(const ObjCMessageExpr *Node)
void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D)
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
void VisitTypeTemplateArgument(const TemplateArgument &TA)
ObjCBoxedExpr - used for generalized expression boxing.
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node)
void VisitRecordDecl(const RecordDecl *D)
A boolean literal, per ([C++ lex.bool] Boolean literals).
void VisitLinkageSpecDecl(const LinkageSpecDecl *D)
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node)
SwitchStmt - This represents a 'switch' stmt.
AssociationTy< true > ConstAssociation
Represents a linkage specification.
A trivial tuple used to represent a source range.
WhileStmt - This represents a 'while' stmt.
static const TerminalColor IndentColor
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA)
void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node)
void VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *Node)
Represents a C++ namespace alias.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents the canonical version of C arrays with a specified constant size.
Represents C++ using-directive.
void VisitAutoType(const AutoType *T)
A binding in a decomposition declaration.
void VisitFunctionProtoType(const FunctionProtoType *T)
Encodes a location in the source.
void VisitUnaryTransformType(const UnaryTransformType *T)
This represents a decl that may have a name.
void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D)
A (possibly-)qualified type.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node)
void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node)
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Represents a member of a struct/union/class.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a type template specialization; the template must be a class template, a type alias templa...
IfStmt - This represents an if/then/else.
GotoStmt - This represents a direct goto.
Describes an C or C++ initializer list.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
void VisitNullPtrTemplateArgument(const TemplateArgument &TA)
void VisitNamespaceDecl(const NamespaceDecl *D)
void visitParamCommandComment(const comments::ParamCommandComment *C, const comments::FullComment *FC)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node)
void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node)
A C++ static_cast expression (C++ [expr.static.cast]).
Describes how types, statements, expressions, and declarations should be printed.
void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node)
void VisitOMPRequiresDecl(const OMPRequiresDecl *D)
FunctionType - C99 6.7.5.3 - Function Declarators.
Represents the body of a CapturedStmt, and serves as its DeclContext.
TextNodeDumper(raw_ostream &OS, const ASTContext &Context, bool ShowColors)
void VisitFunctionDecl(const FunctionDecl *D)
void VisitTemplateTemplateArgument(const TemplateArgument &TA)
void VisitUsingEnumDecl(const UsingEnumDecl *D)
void VisitRValueReferenceType(const ReferenceType *T)
This class handles loading and caching of source files into memory.
void VisitCXXRecordDecl(const CXXRecordDecl *D)
The base class of the type hierarchy.
void VisitVarTemplateDecl(const VarTemplateDecl *D)
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
void VisitTypedefType(const TypedefType *T)
void visitBlockCommandComment(const comments::BlockCommandComment *C, const comments::FullComment *)
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D)
void VisitPragmaCommentDecl(const PragmaCommentDecl *D)
void VisitOMPIteratorExpr(const OMPIteratorExpr *Node)
void VisitSizeOfPackExpr(const SizeOfPackExpr *Node)
void VisitIfStmt(const IfStmt *Node)
void VisitFloatingLiteral(const FloatingLiteral *Node)
Represents a dependent using declaration which was marked with typename.
void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D)
void visitInlineCommandComment(const comments::InlineCommandComment *C, const comments::FullComment *)
Declaration of a template function.
void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node)
void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D)
Represents Objective-C's @catch statement.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
A simple visitor class that helps create template argument visitors.
CompoundStmt - This represents a group of statements like { stmt stmt }.
void VisitVectorType(const VectorType *T)
ObjCSelectorExpr used for @selector in Objective-C.
Represents a pack expansion of types.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
This represents '#pragma omp declare reduction ...' directive.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents an expression that computes the length of a parameter pack.
void VisitFriendDecl(const FriendDecl *D)
Represents binding an expression to a temporary.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D)
void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node)
A builtin binary operation expression such as "x + y" or "x <= y".
This is a basic class for representing single OpenMP clause.
void visitTParamCommandComment(const comments::TParamCommandComment *C, const comments::FullComment *FC)
void VisitRequiresExpr(const RequiresExpr *Node)
void VisitCastExpr(const CastExpr *Node)
Declaration of a C++2a concept.
void VisitImportDecl(const ImportDecl *D)
void VisitCallExpr(const CallExpr *Node)
Represents a GCC generic vector type.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Represents difference between two FPOptions values.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void VisitPackTemplateArgument(const TemplateArgument &TA)
void VisitEnumConstantDecl(const EnumConstantDecl *D)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
void VisitBlockDecl(const BlockDecl *D)
void VisitTypedefDecl(const TypedefDecl *D)
void VisitConstructorUsingShadowDecl(const ConstructorUsingShadowDecl *D)
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D)
Represents a template argument.
void VisitUsingDecl(const UsingDecl *D)
A static requirement that can be used in a requires-expression to check properties of types and expre...
void VisitPackExpansionType(const PackExpansionType *T)
void VisitCXXStaticCastExpr(const CXXStaticCastExpr *Node)
Represents the declaration of a label.
void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D)
void VisitSwitchStmt(const SwitchStmt *Node)
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
void VisitBindingDecl(const BindingDecl *D)
void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D)
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void VisitIntegerLiteral(const IntegerLiteral *Node)
void VisitPragmaDetectMismatchDecl(const PragmaDetectMismatchDecl *D)
Represents a variable declaration or definition.
Represents the dependent type named by a dependently-scoped typename using declaration,...
void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node)
StringLiteral - This represents a string literal expression, e.g.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
void VisitMemberExpr(const MemberExpr *Node)
void AddChild(Fn DoAddChild)
Add a child of the current node. Calls DoAddChild without arguments.
An instance of this object exists for each enum constant that is defined.
void VisitUnresolvedUsingType(const UnresolvedUsingType *T)
void VisitCompoundStmt(const CompoundStmt *Node)
ObjCEncodeExpr, used for @encode in Objective-C.
Represents a dependent using declaration which was not marked with typename.
void VisitVariableArrayType(const VariableArrayType *T)
A simple visitor class that helps create attribute visitors.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Declaration of a template type parameter.
An expression that sends a message to the given Objective-C object or class.
void VisitObjCImplementationDecl(const ObjCImplementationDecl *D)
void visitHTMLStartTagComment(const comments::HTMLStartTagComment *C, const comments::FullComment *)
void VisitAddrLabelExpr(const AddrLabelExpr *Node)
Represents a C++ using-declaration.
void visitVerbatimBlockComment(const comments::VerbatimBlockComment *C, const comments::FullComment *)
ObjCCategoryDecl - Represents a category declaration.
void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D)
void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Represents a C++ using-enum-declaration.
Represents a C++ struct/union/class.
void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node)
void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *Node)
void VisitExpressionTemplateArgument(const TemplateArgument &TA)
Represents an array type in C++ whose size is a value-dependent expression.
Represents a C array with a specified size that is not an integer-constant-expression.
void VisitTemplateTypeParmType(const TemplateTypeParmType *T)
TextTreeStructure(raw_ostream &OS, bool ShowColors)
void dumpLocation(SourceLocation Loc)
void dumpBareDeclRef(const Decl *D)
void VisitLabelStmt(const LabelStmt *Node)
Declaration of a class template.
A simple visitor class that helps create declaration visitors.
void visitVerbatimBlockLineComment(const comments::VerbatimBlockLineComment *C, const comments::FullComment *)
void VisitObjCInterfaceType(const ObjCInterfaceType *T)
Represents a prototype with parameter type info, e.g.
Pseudo declaration for capturing expressions.
ObjCProtocolExpr used for protocol expression in Objective-C.
void VisitTypeTraitExpr(const TypeTraitExpr *Node)
void VisitEnumDecl(const EnumDecl *D)
void VisitInjectedClassNameType(const InjectedClassNameType *T)
Represents a delete expression for memory deallocation and destructor calls, e.g.
void AddChild(StringRef Label, Fn DoAddChild)
Add a child of the current node with an optional label.
Decl - This represents one declaration (or definition), e.g.
Represents one property declaration in an Objective-C interface.
AddrLabelExpr - The GNU address of label extension, representing &&label.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
void VisitAccessSpecDecl(const AccessSpecDecl *D)
void VisitImplicitCastExpr(const ImplicitCastExpr *Node)
void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node)
void VisitCharacterLiteral(const CharacterLiteral *Node)
void VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D)
The injected class name of a C++ class template or class template partial specialization.
void VisitBinaryOperator(const BinaryOperator *Node)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D)
CompoundAssignOperator - For compound assignments (e.g.
void VisitCapturedDecl(const CapturedDecl *D)
void VisitCXXThisExpr(const CXXThisExpr *Node)
void dumpName(const NamedDecl *ND)
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
void VisitUsingType(const UsingType *T)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D)
void VisitOMPExecutableDirective(const OMPExecutableDirective *D)
This is a basic class for representing single OpenMP executable directive.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void VisitWhileStmt(const WhileStmt *Node)
Represents the declaration of an Objective-C type parameter.
Represents the this expression in C++.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
void VisitIntegralTemplateArgument(const TemplateArgument &TA)
ObjCMethodDecl - Represents an instance or class method declaration.
[C99 6.4.2.2] - A predefined identifier such as func.
void dumpType(QualType T)
void dumpPointer(const void *Ptr)
void VisitFixedPointLiteral(const FixedPointLiteral *Node)
void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D)
void VisitExpressionTraitExpr(const ExpressionTraitExpr *Node)
Represents a field injected from an anonymous union/struct into the parent scope.
void VisitGotoStmt(const GotoStmt *Node)
void dumpBareType(QualType T, bool Desugar=true)
void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node)
void VisitObjCPropertyDecl(const ObjCPropertyDecl *D)
void VisitConstantExpr(const ConstantExpr *Node)
Stmt - This represents one statement.
ObjCIvarDecl - Represents an ObjC instance variable.
void visitHTMLEndTagComment(const comments::HTMLEndTagComment *C, const comments::FullComment *)
void VisitExprWithCleanups(const ExprWithCleanups *Node)
Represents a C11 generic selection.
void VisitVarDecl(const VarDecl *D)
void VisitObjCMethodDecl(const ObjCMethodDecl *D)
void visitVerbatimLineComment(const comments::VerbatimLineComment *C, const comments::FullComment *)
void dumpDeclRef(const Decl *D, StringRef Label={})
void VisitLabelDecl(const LabelDecl *D)
Represents an Objective-C protocol declaration.
void VisitUnaryOperator(const UnaryOperator *Node)
Attr - This represents one attribute.
This represents '#pragma omp requires...' directive.
void VisitObjCCategoryDecl(const ObjCCategoryDecl *D)
void VisitDeducedTemplateSpecializationType(const DeducedTemplateSpecializationType *T)
Abstract class common to all of the C++ "named"/"keyword" casts.
void VisitInitListExpr(const InitListExpr *ILE)
void VisitNullTemplateArgument(const TemplateArgument &TA)
void VisitIndirectFieldDecl(const IndirectFieldDecl *D)
void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node)
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
void VisitStringLiteral(const StringLiteral *Str)
void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *Node)
Declaration of an alias template.
void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node)
void VisitGenericSelectionExpr(const GenericSelectionExpr *E)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
void VisitDependentSizedArrayType(const DependentSizedArrayType *T)
void VisitCXXDeleteExpr(const CXXDeleteExpr *Node)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
void dumpAccessSpecifier(AccessSpecifier AS)
void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node)
Base for LValueReferenceType and RValueReferenceType.
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D)
void VisitObjCProtocolDecl(const ObjCProtocolDecl *D)
Represents a #pragma detect_mismatch line.
void dumpSourceRange(SourceRange R)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
void VisitCXXConstructExpr(const CXXConstructExpr *Node)
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Declaration of a variable template.
void visitTextComment(const comments::TextComment *C, const comments::FullComment *)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
void VisitDeclRefExpr(const DeclRefExpr *Node)
void dumpCleanupObject(const ExprWithCleanups::CleanupObject &C)
void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D)
Represents a C++ base or member initializer.
A class which contains all the information about a particular captured value.
void VisitCXXNewExpr(const CXXNewExpr *Node)
void VisitPredefinedExpr(const PredefinedExpr *Node)
void VisitUsingShadowDecl(const UsingShadowDecl *D)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents an extended vector type where either the type or size is dependent.
void VisitTemplateSpecializationType(const TemplateSpecializationType *T)
void VisitCompoundAssignOperator(const CompoundAssignOperator *Node)
A reference to a declared variable, function, enum, etc.
Represent a C++ namespace.
void VisitFieldDecl(const FieldDecl *D)
Represents a function declaration or definition.
Represents a struct/union/class.
void VisitDeclarationTemplateArgument(const TemplateArgument &TA)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node)
void Visit(const comments::Comment *C, const comments::FullComment *FC)
void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node)
A call to an overloaded operator written using operator syntax.
Interfaces are the core concept in Objective-C for object oriented design.
void VisitCaseStmt(const CaseStmt *Node)
void VisitObjCIvarDecl(const ObjCIvarDecl *D)
void VisitConstantArrayType(const ConstantArrayType *T)
Represents a call to a C++ constructor.
void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D)
ObjCIvarRefExpr - A reference to an ObjC instance variable.
void VisitArrayType(const ArrayType *T)
void VisitFunctionType(const FunctionType *T)
void VisitTypeAliasDecl(const TypeAliasDecl *D)
void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *Node)
void VisitTagType(const TagType *T)
void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D)