22 namespace ast_type_traits {
24 const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
25 { NKI_None,
"<None>" },
26 { NKI_None,
"TemplateArgument" },
27 { NKI_None,
"TemplateName" },
28 { NKI_None,
"NestedNameSpecifierLoc" },
29 { NKI_None,
"QualType" },
30 { NKI_None,
"TypeLoc" },
31 { NKI_None,
"CXXCtorInitializer" },
32 { NKI_None,
"NestedNameSpecifier" },
34 #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" }, 35 #include "clang/AST/DeclNodes.inc" 37 #define STMT(DERIVED, BASE) { NKI_##BASE, #DERIVED }, 38 #include "clang/AST/StmtNodes.inc" 40 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" }, 41 #include "clang/AST/TypeNodes.inc" 42 { NKI_None,
"OMPClause" },
43 #define OPENMP_CLAUSE(TextualSpelling, Class) {NKI_OMPClause, #Class}, 44 #include "clang/Basic/OpenMPKinds.def" 48 return isBaseOf(KindId, Other.KindId, Distance);
53 if (Base == NKI_None || Derived == NKI_None)
return false;
55 while (Derived != Base && Derived != NKI_None) {
56 Derived = AllKindInfo[Derived].ParentId;
61 return Derived == Base;
68 if (Kind1.
isBaseOf(Kind2))
return Kind2;
69 if (Kind2.
isBaseOf(Kind1))
return Kind1;
75 NodeKindId
Parent = Kind1.KindId;
76 while (!
isBaseOf(Parent, Kind2.KindId,
nullptr) && Parent != NKI_None) {
77 Parent = AllKindInfo[
Parent].ParentId;
84 #define DECL(DERIVED, BASE) \ 85 case Decl::DERIVED: return ASTNodeKind(NKI_##DERIVED##Decl); 86 #define ABSTRACT_DECL(D) 87 #include "clang/AST/DeclNodes.inc" 89 llvm_unreachable(
"invalid decl kind");
95 #define STMT(CLASS, PARENT) \ 96 case Stmt::CLASS##Class: return ASTNodeKind(NKI_##CLASS); 97 #define ABSTRACT_STMT(S) 98 #include "clang/AST/StmtNodes.inc" 100 llvm_unreachable(
"invalid stmt kind");
105 #define TYPE(Class, Base) \ 106 case Type::Class: return ASTNodeKind(NKI_##Class##Type); 107 #define ABSTRACT_TYPE(Class, Base) 108 #include "clang/AST/TypeNodes.inc" 110 llvm_unreachable(
"invalid type kind");
115 #define OPENMP_CLAUSE(Name, Class) \ 116 case OMPC_##Name: return ASTNodeKind(NKI_##Class); 117 #include "clang/Basic/OpenMPKinds.def" 123 llvm_unreachable(
"unexpected OpenMP clause kind");
125 llvm_unreachable(
"invalid stmt kind");
140 OS <<
"(empty NestedNameSpecifierLoc)";
141 }
else if (
const QualType *QT = get<QualType>())
143 else if (
const TypeLoc *TL = get<TypeLoc>())
144 TL->getType().print(OS, PP);
145 else if (
const Decl *D = get<Decl>())
147 else if (
const Stmt *S = get<Stmt>())
148 S->printPretty(OS,
nullptr, PP);
149 else if (
const Type *T = get<Type>())
152 OS <<
"Unable to print values of type " <<
NodeKind.asStringRef() <<
"\n";
156 if (
const Decl *D = get<Decl>())
158 else if (
const Stmt *S = get<Stmt>())
160 else if (
const Type *T = get<Type>())
163 OS <<
"Unable to dump values of type " <<
NodeKind.asStringRef() <<
"\n";
168 return CCI->getSourceRange();
170 return NNSL->getSourceRange();
171 if (
const TypeLoc *TL = get<TypeLoc>())
172 return TL->getSourceRange();
173 if (
const Decl *D = get<Decl>())
174 return D->getSourceRange();
175 if (
const Stmt *S = get<Stmt>())
176 return S->getSourceRange();
177 if (
const auto *C = get<OMPClause>())
178 return SourceRange(C->getBeginLoc(), C->getEndLoc());
Defines the clang::ASTContext interface.
A (possibly-)qualified type.
static ASTNodeKind getFromNode(const Decl &D)
Stmt - This represents one statement.
StringRef asStringRef() const
String representation of the kind.
Decl - This represents one declaration (or definition), e.g.
The base class of the type hierarchy.
Describes how types, statements, expressions, and declarations should be printed. ...
Base wrapper for a particular "section" of type source info.
A C++ nested-name-specifier augmented with source location information.
ASTNodeKind()
Empty identifier. It matches nothing.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void dump(llvm::raw_ostream &OS, SourceManager &SM) const
Dumps the node to the given output stream.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Represents a C++ template name within the type system.
static ASTNodeKind getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2)
Return the most derived type between Kind1 and Kind2.
SourceRange getSourceRange() const
For nodes which represent textual entities in the source code, return their SourceRange.
This file defines OpenMP AST classes for clauses.
NodeKind
A kind of a syntax node, used for implementing casts.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This is a basic class for representing single OpenMP clause.
TypeClass getTypeClass() const
bool isBaseOf(ASTNodeKind Other, unsigned *Distance=nullptr) const
Returns true if this is a base kind of (or same as) Other.
Represents a template argument.
static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1, ASTNodeKind Kind2)
Return the most derived common ancestor between Kind1 and Kind2.
Dataflow Directional Tag Classes.
StmtClass getStmtClass() const
Represents a C++ base or member initializer.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
A trivial tuple used to represent a source range.
This class handles loading and caching of source files into memory.
void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const
Prints the node to the given output stream.