1*13fbcb42Sjoerginclude "clang/Basic/ASTNode.td"
2*13fbcb42Sjoerg
3*13fbcb42Sjoergclass TypeNode<TypeNode base, bit abstract = 0> : ASTNode {
406f32e7eSjoerg	TypeNode Base = base;
506f32e7eSjoerg  bit Abstract = abstract;
606f32e7eSjoerg}
706f32e7eSjoerg
806f32e7eSjoerg/// A type node that is only used to represent dependent types in C++.  For
906f32e7eSjoerg/// example, DependentTemplateSpecializationType is used to represent types
1006f32e7eSjoerg/// where the base template-id is dependent (such as `T::foo<U>`).  Code
1106f32e7eSjoerg/// that only works with non-dependent types can ignore these type nodes.
1206f32e7eSjoergclass AlwaysDependent {}
1306f32e7eSjoerg
1406f32e7eSjoerg/// A type node that is never used to represent a canonical type, which is to
1506f32e7eSjoerg/// say that it always represents some sort of type "sugar" which can
1606f32e7eSjoerg/// (supposedly) be erased without affecting the formal behavior of the
1706f32e7eSjoerg/// language.  For example, in standard C/C++, typedefs do not introduce new
1806f32e7eSjoerg/// types and do not affect the semantics of the program.  Code that only
1906f32e7eSjoerg/// works with canonical types can ignore these type nodes.
2006f32e7eSjoerg///
2106f32e7eSjoerg/// Note that this simple story about non-canonical types is not the whole
2206f32e7eSjoerg/// truth.  Languages and extensions often have formation rules which differ
2306f32e7eSjoerg/// based on how a type is spelled and which therefore are not consistent
2406f32e7eSjoerg/// with immediately stipping away type sugar.  More critically, attributes on
2506f32e7eSjoerg/// typedefs can have semantic impacts in ways that are only reflected in our
2606f32e7eSjoerg/// AST by preserving the typedef sugar; for example, we do not otherwise
2706f32e7eSjoerg/// represent the alignment attribute on typedefs, and so it is necessary to
2806f32e7eSjoerg/// preserve typedef structure into most parts of IR generation.
2906f32e7eSjoergclass NeverCanonical {}
3006f32e7eSjoerg
3106f32e7eSjoerg/// A type node that only represents a canonical type in some dependent cases.
3206f32e7eSjoerg/// For example, `std::vector<int>` (a TemplateSpecializationType) is
3306f32e7eSjoerg/// considered to be a non-canonical representation for the RecordType
3406f32e7eSjoerg/// referencing the concrete ClassTemplateSpecializationDecl; but
3506f32e7eSjoerg/// `std::vector<T>` cannot be resolved to a concrete specialization
3606f32e7eSjoerg/// and so remains canonical.  Code which only works with non-dependent
3706f32e7eSjoerg/// canonical types can ignore these nodes.
3806f32e7eSjoergclass NeverCanonicalUnlessDependent {}
3906f32e7eSjoerg
4006f32e7eSjoerg/// A type node which never has component type structure.  Some code may be
4106f32e7eSjoerg/// able to operate on leaf types faster than they can on non-leaf types.
4206f32e7eSjoerg///
4306f32e7eSjoerg/// For example, the function type `void (int)` is not a leaf type because it
4406f32e7eSjoerg/// is structurally composed of component types (`void` and `int`).
4506f32e7eSjoerg///
4606f32e7eSjoerg/// A struct type is a leaf type because its field types are not part of its
4706f32e7eSjoerg/// type-expression.
4806f32e7eSjoerg///
4906f32e7eSjoerg/// Nodes like `TypedefType` which are syntactically leaves but can desugar
5006f32e7eSjoerg/// to types that may not be leaves should not declare this.
5106f32e7eSjoergclass LeafType {}
5206f32e7eSjoerg
5306f32e7eSjoergdef Type : TypeNode<?, 1>;
5406f32e7eSjoergdef BuiltinType : TypeNode<Type>, LeafType;
5506f32e7eSjoergdef ComplexType : TypeNode<Type>;
5606f32e7eSjoergdef PointerType : TypeNode<Type>;
5706f32e7eSjoergdef BlockPointerType : TypeNode<Type>;
5806f32e7eSjoergdef ReferenceType : TypeNode<Type, 1>;
5906f32e7eSjoergdef LValueReferenceType : TypeNode<ReferenceType>;
6006f32e7eSjoergdef RValueReferenceType : TypeNode<ReferenceType>;
6106f32e7eSjoergdef MemberPointerType : TypeNode<Type>;
6206f32e7eSjoergdef ArrayType : TypeNode<Type, 1>;
6306f32e7eSjoergdef ConstantArrayType : TypeNode<ArrayType>;
6406f32e7eSjoergdef IncompleteArrayType : TypeNode<ArrayType>;
6506f32e7eSjoergdef VariableArrayType : TypeNode<ArrayType>;
6606f32e7eSjoergdef DependentSizedArrayType : TypeNode<ArrayType>, AlwaysDependent;
6706f32e7eSjoergdef DependentSizedExtVectorType : TypeNode<Type>, AlwaysDependent;
6806f32e7eSjoergdef DependentAddressSpaceType : TypeNode<Type>, AlwaysDependent;
6906f32e7eSjoergdef VectorType : TypeNode<Type>;
7006f32e7eSjoergdef DependentVectorType : TypeNode<Type>, AlwaysDependent;
7106f32e7eSjoergdef ExtVectorType : TypeNode<VectorType>;
72*13fbcb42Sjoergdef MatrixType : TypeNode<Type, 1>;
73*13fbcb42Sjoergdef ConstantMatrixType : TypeNode<MatrixType>;
74*13fbcb42Sjoergdef DependentSizedMatrixType : TypeNode<MatrixType>, AlwaysDependent;
7506f32e7eSjoergdef FunctionType : TypeNode<Type, 1>;
7606f32e7eSjoergdef FunctionProtoType : TypeNode<FunctionType>;
7706f32e7eSjoergdef FunctionNoProtoType : TypeNode<FunctionType>;
7806f32e7eSjoergdef UnresolvedUsingType : TypeNode<Type>, AlwaysDependent;
7906f32e7eSjoergdef ParenType : TypeNode<Type>, NeverCanonical;
8006f32e7eSjoergdef TypedefType : TypeNode<Type>, NeverCanonical;
8106f32e7eSjoergdef MacroQualifiedType : TypeNode<Type>, NeverCanonical;
8206f32e7eSjoergdef AdjustedType : TypeNode<Type>, NeverCanonical;
8306f32e7eSjoergdef DecayedType : TypeNode<AdjustedType>, NeverCanonical;
8406f32e7eSjoergdef TypeOfExprType : TypeNode<Type>, NeverCanonicalUnlessDependent;
8506f32e7eSjoergdef TypeOfType : TypeNode<Type>, NeverCanonicalUnlessDependent;
8606f32e7eSjoergdef DecltypeType : TypeNode<Type>, NeverCanonicalUnlessDependent;
8706f32e7eSjoergdef UnaryTransformType : TypeNode<Type>, NeverCanonicalUnlessDependent;
8806f32e7eSjoergdef TagType : TypeNode<Type, 1>;
8906f32e7eSjoergdef RecordType : TypeNode<TagType>, LeafType;
9006f32e7eSjoergdef EnumType : TypeNode<TagType>, LeafType;
9106f32e7eSjoergdef ElaboratedType : TypeNode<Type>, NeverCanonical;
9206f32e7eSjoergdef AttributedType : TypeNode<Type>, NeverCanonical;
9306f32e7eSjoergdef TemplateTypeParmType : TypeNode<Type>, AlwaysDependent, LeafType;
9406f32e7eSjoergdef SubstTemplateTypeParmType : TypeNode<Type>, NeverCanonical;
9506f32e7eSjoergdef SubstTemplateTypeParmPackType : TypeNode<Type>, AlwaysDependent;
9606f32e7eSjoergdef TemplateSpecializationType : TypeNode<Type>, NeverCanonicalUnlessDependent;
9706f32e7eSjoergdef DeducedType : TypeNode<Type, 1>;
9806f32e7eSjoergdef AutoType : TypeNode<DeducedType>;
9906f32e7eSjoergdef DeducedTemplateSpecializationType : TypeNode<DeducedType>;
10006f32e7eSjoergdef InjectedClassNameType : TypeNode<Type>, AlwaysDependent, LeafType;
10106f32e7eSjoergdef DependentNameType : TypeNode<Type>, AlwaysDependent;
10206f32e7eSjoergdef DependentTemplateSpecializationType : TypeNode<Type>, AlwaysDependent;
103*13fbcb42Sjoergdef PackExpansionType : TypeNode<Type>, AlwaysDependent;
10406f32e7eSjoergdef ObjCTypeParamType : TypeNode<Type>, NeverCanonical;
10506f32e7eSjoergdef ObjCObjectType : TypeNode<Type>;
10606f32e7eSjoergdef ObjCInterfaceType : TypeNode<ObjCObjectType>, LeafType;
10706f32e7eSjoergdef ObjCObjectPointerType : TypeNode<Type>;
10806f32e7eSjoergdef PipeType : TypeNode<Type>;
10906f32e7eSjoergdef AtomicType : TypeNode<Type>;
110*13fbcb42Sjoergdef ExtIntType : TypeNode<Type>;
111*13fbcb42Sjoergdef DependentExtIntType : TypeNode<Type>, AlwaysDependent;
112