TypeNodes.td revision 360784
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 FunctionType : TypeNode<Type, 1>;
73def FunctionProtoType : TypeNode<FunctionType>;
74def FunctionNoProtoType : TypeNode<FunctionType>;
75def UnresolvedUsingType : TypeNode<Type>, AlwaysDependent;
76def ParenType : TypeNode<Type>, NeverCanonical;
77def TypedefType : TypeNode<Type>, NeverCanonical;
78def MacroQualifiedType : TypeNode<Type>, NeverCanonical;
79def AdjustedType : TypeNode<Type>, NeverCanonical;
80def DecayedType : TypeNode<AdjustedType>, NeverCanonical;
81def TypeOfExprType : TypeNode<Type>, NeverCanonicalUnlessDependent;
82def TypeOfType : TypeNode<Type>, NeverCanonicalUnlessDependent;
83def DecltypeType : TypeNode<Type>, NeverCanonicalUnlessDependent;
84def UnaryTransformType : TypeNode<Type>, NeverCanonicalUnlessDependent;
85def TagType : TypeNode<Type, 1>;
86def RecordType : TypeNode<TagType>, LeafType;
87def EnumType : TypeNode<TagType>, LeafType;
88def ElaboratedType : TypeNode<Type>, NeverCanonical;
89def AttributedType : TypeNode<Type>, NeverCanonical;
90def TemplateTypeParmType : TypeNode<Type>, AlwaysDependent, LeafType;
91def SubstTemplateTypeParmType : TypeNode<Type>, NeverCanonical;
92def SubstTemplateTypeParmPackType : TypeNode<Type>, AlwaysDependent;
93def TemplateSpecializationType : TypeNode<Type>, NeverCanonicalUnlessDependent;
94def DeducedType : TypeNode<Type, 1>;
95def AutoType : TypeNode<DeducedType>;
96def DeducedTemplateSpecializationType : TypeNode<DeducedType>;
97def InjectedClassNameType : TypeNode<Type>, AlwaysDependent, LeafType;
98def DependentNameType : TypeNode<Type>, AlwaysDependent;
99def DependentTemplateSpecializationType : TypeNode<Type>, AlwaysDependent;
100def PackExpansionType : TypeNode<Type>, NeverCanonicalUnlessDependent;
101def ObjCTypeParamType : TypeNode<Type>, NeverCanonical;
102def ObjCObjectType : TypeNode<Type>;
103def ObjCInterfaceType : TypeNode<ObjCObjectType>, LeafType;
104def ObjCObjectPointerType : TypeNode<Type>;
105def PipeType : TypeNode<Type>;
106def AtomicType : TypeNode<Type>;
107