26const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
28 {NKI_None,
"TemplateArgument"},
29 {NKI_None,
"TemplateArgumentLoc"},
30 {NKI_None,
"LambdaCapture"},
31 {NKI_None,
"TemplateName"},
32 {NKI_None,
"NestedNameSpecifierLoc"},
33 {NKI_None,
"QualType"},
34#define TYPELOC(CLASS, PARENT) {NKI_##PARENT, #CLASS "TypeLoc"},
35#include "clang/AST/TypeLocNodes.def"
36 {NKI_None,
"TypeLoc"},
37 {NKI_None,
"CXXBaseSpecifier"},
38 {NKI_None,
"CXXCtorInitializer"},
39 {NKI_None,
"NestedNameSpecifier"},
41#define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" },
42#include "clang/AST/DeclNodes.inc"
44#define STMT(DERIVED, BASE) { NKI_##BASE, #DERIVED },
45#include "clang/AST/StmtNodes.inc"
47#define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
48#include "clang/AST/TypeNodes.inc"
49 {NKI_None,
"OMPClause"},
50#define GEN_CLANG_CLAUSE_CLASS
51#define CLAUSE_CLASS(Enum, Str, Class) {NKI_OMPClause, #Class},
52#include "llvm/Frontend/OpenMP/OMP.inc"
54#define ATTR(A) {NKI_Attr, #A "Attr"},
55#include "clang/Basic/AttrList.inc"
56 {NKI_None,
"ObjCProtocolLoc"},
60 return isBaseOf(KindId, Other.KindId);
64 return isBaseOf(KindId, Other.KindId, Distance);
68 if (
Base == NKI_None || Derived == NKI_None)
70 while (Derived !=
Base && Derived != NKI_None) {
71 Derived = AllKindInfo[Derived].ParentId;
73 return Derived ==
Base;
78 if (
Base == NKI_None || Derived == NKI_None)
return false;
80 while (Derived !=
Base && Derived != NKI_None) {
81 Derived = AllKindInfo[Derived].ParentId;
86 return Derived ==
Base;
90 NodeKindId LastId = KindId;
92 NodeKindId ParentId = AllKindInfo[LastId].ParentId;
93 if (ParentId == NKI_None)
104 if (Kind1.
isBaseOf(Kind2))
return Kind2;
105 if (Kind2.
isBaseOf(Kind1))
return Kind1;
111 NodeKindId
Parent = Kind1.KindId;
120#define DECL(DERIVED, BASE) \
121 case Decl::DERIVED: return ASTNodeKind(NKI_##DERIVED##Decl);
122#define ABSTRACT_DECL(D)
123#include "clang/AST/DeclNodes.inc"
125 llvm_unreachable(
"invalid decl kind");
129 switch (S.getStmtClass()) {
131#define STMT(CLASS, PARENT) \
132 case Stmt::CLASS##Class: return ASTNodeKind(NKI_##CLASS);
133#define ABSTRACT_STMT(S)
134#include "clang/AST/StmtNodes.inc"
136 llvm_unreachable(
"invalid stmt kind");
141#define TYPE(Class, Base) \
142 case Type::Class: return ASTNodeKind(NKI_##Class##Type);
143#define ABSTRACT_TYPE(Class, Base)
144#include "clang/AST/TypeNodes.inc"
146 llvm_unreachable(
"invalid type kind");
151#define ABSTRACT_TYPELOC(CLASS, PARENT)
152#define TYPELOC(CLASS, PARENT) \
153 case TypeLoc::CLASS: \
154 return ASTNodeKind(NKI_##CLASS##TypeLoc);
155#include "clang/AST/TypeLocNodes.def"
157 llvm_unreachable(
"invalid typeloc kind");
161 switch (
C.getClauseKind()) {
162#define GEN_CLANG_CLAUSE_CLASS
163#define CLAUSE_CLASS(Enum, Str, Class) \
164 case llvm::omp::Clause::Enum: \
165 return ASTNodeKind(NKI_##Class);
166#define CLAUSE_NO_CLASS(Enum, Str) \
167 case llvm::omp::Clause::Enum: \
168 llvm_unreachable("unexpected OpenMP clause kind");
169#include "llvm/Frontend/OpenMP/OMP.inc"
171 llvm_unreachable(
"invalid omp clause kind");
178 return ASTNodeKind(NKI_##A##Attr);
179#include "clang/Basic/AttrList.inc"
181 llvm_unreachable(
"invalid attr kind");
187 TA->print(PP, OS,
true);
189 TAL->getArgument().print(PP, OS,
true);
198 OS <<
"(empty NestedNameSpecifierLoc)";
199 }
else if (
const QualType *QT = get<QualType>())
201 else if (
const TypeLoc *TL = get<TypeLoc>())
202 TL->getType().print(OS, PP);
203 else if (
const Decl *D = get<Decl>())
205 else if (
const Stmt *S = get<Stmt>())
206 S->printPretty(OS,
nullptr, PP);
207 else if (
const Type *T = get<Type>())
209 else if (
const Attr *A = get<Attr>())
210 A->printPretty(OS, PP);
212 P->getProtocol()->print(OS, PP);
214 OS <<
"Unable to print values of type " << NodeKind.
asStringRef() <<
"\n";
219 if (
const Decl *D = get<Decl>())
221 else if (
const Stmt *S = get<Stmt>())
222 S->dump(OS, Context);
223 else if (
const Type *T = get<Type>())
224 T->dump(OS, Context);
226 OS <<
"Unable to dump values of type " << NodeKind.
asStringRef() <<
"\n";
231 return CCI->getSourceRange();
233 return NNSL->getSourceRange();
234 if (
const TypeLoc *TL = get<TypeLoc>())
235 return TL->getSourceRange();
236 if (
const Decl *D = get<Decl>())
237 return D->getSourceRange();
238 if (
const Stmt *S = get<Stmt>())
239 return S->getSourceRange();
241 return TAL->getSourceRange();
242 if (
const auto *
C = get<OMPClause>())
244 if (
const auto *CBS = get<CXXBaseSpecifier>())
245 return CBS->getSourceRange();
246 if (
const auto *A = get<Attr>())
247 return A->getRange();
249 return P->getSourceRange();
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP AST classes for clauses.
Defines the clang::TypeLoc interface and its subclasses.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
StringRef asStringRef() const
String representation of the kind.
bool isBaseOf(ASTNodeKind Other) const
Returns true if this is a base kind of (or same as) Other.
constexpr ASTNodeKind()
Empty identifier. It matches nothing.
ASTNodeKind getCladeKind() const
static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1, ASTNodeKind Kind2)
Return the most derived common ancestor between Kind1 and Kind2.
static ASTNodeKind getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2)
Return the most derived type between Kind1 and Kind2.
static ASTNodeKind getFromNode(const Decl &D)
Attr - This represents one attribute.
attr::Kind getKind() const
Represents a C++ base or member initializer.
Decl - This represents one declaration (or definition), e.g.
SourceRange getSourceRange() const
For nodes which represent textual entities in the source code, return their SourceRange.
void dump(llvm::raw_ostream &OS, const ASTContext &Context) const
Dumps the node to the given output stream.
void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const
Prints the node to the given output stream.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This is a basic class for representing single OpenMP clause.
A (possibly-)qualified type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Location wrapper for a TemplateArgument.
Represents a template argument.
Represents a C++ template name within the type system.
Base wrapper for a particular "section" of type source info.
TypeLocClass getTypeLocClass() const
The base class of the type hierarchy.
TypeClass getTypeClass() const
@ C
Languages that the frontend can parse and compile.
Describes how types, statements, expressions, and declarations should be printed.