1include "clang/Basic/ASTNode.td"
2
3class TypeNode<TypeNode base, bit abstract = 0> : ASTNode {
4 TypeNode Base = base;
5 bit Abstract = abstract;
6}
7
8/// A type node that is only used to represent dependent types in C++. For
9/// example, DependentTemplateSpecializationType is used to represent types
10/// where the base template-id is dependent (such as `T::foo<U>`). Code
11/// that only works with non-dependent types can ignore these type nodes.
12class AlwaysDependent {}
13
14/// A type node that is never used to represent a canonical type, which is to
15/// say that it always represents some sort of type "sugar" which can
16/// (supposedly) be erased without affecting the formal behavior of the
17/// language. For example, in standard C/C++, typedefs do not introduce new
18/// types and do not affect the semantics of the program. Code that only
19/// works with canonical types can ignore these type nodes.
20///
21/// Note that this simple story about non-canonical types is not the whole
22/// truth. Languages and extensions often have formation rules which differ
23/// based on how a type is spelled and which therefore are not consistent
24/// with immediately stipping away type sugar. More critically, attributes on
25/// typedefs can have semantic impacts in ways that are only reflected in our
26/// AST by preserving the typedef sugar; for example, we do not otherwise
27/// represent the alignment attribute on typedefs, and so it is necessary to
28/// preserve typedef structure into most parts of IR generation.
29class NeverCanonical {}
30
31/// A type node that only represents a canonical type in some dependent cases.
32/// For example, `std::vector<int>` (a TemplateSpecializationType) is
33/// considered to be a non-canonical representation for the RecordType
34/// referencing the concrete ClassTemplateSpecializationDecl; but
35/// `std::vector<T>` cannot be resolved to a concrete specialization
36/// and so remains canonical. Code which only works with non-dependent
37/// canonical types can ignore these nodes.
38class NeverCanonicalUnlessDependent {}
39
40/// A type node which never has component type structure. Some code may be
41/// able to operate on leaf types faster than they can on non-leaf types.
42///
43/// For example, the function type `void (int)` is not a leaf type because it
44/// is structurally composed of component types (`void` and `int`).
45///
46/// A struct type is a leaf type because its field types are not part of its
47/// type-expression.
48///
49/// Nodes like `TypedefType` which are syntactically leaves but can desugar
50/// to types that may not be leaves should not declare this.
51class LeafType {}
52
53def Type : TypeNode<?, 1>;
54def BuiltinType : TypeNode<Type>, LeafType;
55def ComplexType : TypeNode<Type>;
56def PointerType : TypeNode<Type>;
57def BlockPointerType : TypeNode<Type>;
58def ReferenceType : TypeNode<Type, 1>;
59def LValueReferenceType : TypeNode<ReferenceType>;
60def RValueReferenceType : TypeNode<ReferenceType>;
61def MemberPointerType : TypeNode<Type>;
62def ArrayType : TypeNode<Type, 1>;
63def ConstantArrayType : TypeNode<ArrayType>;
64def IncompleteArrayType : TypeNode<ArrayType>;
65def VariableArrayType : TypeNode<ArrayType>;
66def DependentSizedArrayType : TypeNode<ArrayType>, AlwaysDependent;
67def DependentSizedExtVectorType : TypeNode<Type>, AlwaysDependent;
68def DependentAddressSpaceType : TypeNode<Type>, AlwaysDependent;
69def VectorType : TypeNode<Type>;
70def DependentVectorType : TypeNode<Type>, AlwaysDependent;
71def ExtVectorType : TypeNode<VectorType>;
72def MatrixType : TypeNode<Type, 1>;
73def ConstantMatrixType : TypeNode<MatrixType>;
74def DependentSizedMatrixType : TypeNode<MatrixType>, AlwaysDependent;
75def FunctionType : TypeNode<Type, 1>;
76def FunctionProtoType : TypeNode<FunctionType>;
77def FunctionNoProtoType : TypeNode<FunctionType>;
78def UnresolvedUsingType : TypeNode<Type>, AlwaysDependent;
79def ParenType : TypeNode<Type>, NeverCanonical;
80def TypedefType : TypeNode<Type>, NeverCanonical;
81def MacroQualifiedType : TypeNode<Type>, NeverCanonical;
82def AdjustedType : TypeNode<Type>, NeverCanonical;
83def DecayedType : TypeNode<AdjustedType>, NeverCanonical;
84def TypeOfExprType : TypeNode<Type>, NeverCanonicalUnlessDependent;
85def TypeOfType : TypeNode<Type>, NeverCanonicalUnlessDependent;
86def DecltypeType : TypeNode<Type>, NeverCanonicalUnlessDependent;
87def UnaryTransformType : TypeNode<Type>, NeverCanonicalUnlessDependent;
88def TagType : TypeNode<Type, 1>;
89def RecordType : TypeNode<TagType>, LeafType;
90def EnumType : TypeNode<TagType>, LeafType;
91def ElaboratedType : TypeNode<Type>, NeverCanonical;
92def AttributedType : TypeNode<Type>, NeverCanonical;
93def TemplateTypeParmType : TypeNode<Type>, AlwaysDependent, LeafType;
94def SubstTemplateTypeParmType : TypeNode<Type>, NeverCanonical;
95def SubstTemplateTypeParmPackType : TypeNode<Type>, AlwaysDependent;
96def TemplateSpecializationType : TypeNode<Type>, NeverCanonicalUnlessDependent;
97def DeducedType : TypeNode<Type, 1>;
98def AutoType : TypeNode<DeducedType>;
99def DeducedTemplateSpecializationType : TypeNode<DeducedType>;
100def InjectedClassNameType : TypeNode<Type>, AlwaysDependent, LeafType;
101def DependentNameType : TypeNode<Type>, AlwaysDependent;
102def DependentTemplateSpecializationType : TypeNode<Type>, AlwaysDependent;
103def PackExpansionType : TypeNode<Type>, AlwaysDependent;
104def ObjCTypeParamType : TypeNode<Type>, NeverCanonical;
105def ObjCObjectType : TypeNode<Type>;
106def ObjCInterfaceType : TypeNode<ObjCObjectType>, LeafType;
107def ObjCObjectPointerType : TypeNode<Type>;
108def PipeType : TypeNode<Type>;
109def AtomicType : TypeNode<Type>;
110def ExtIntType : TypeNode<Type>;
111def DependentExtIntType : TypeNode<Type>, AlwaysDependent;
112