@@ -2134,6 +2134,23 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
2134
2134
unsigned hasTypeDifferentFromDecl : 1 ;
2135
2135
};
2136
2136
2137
+ class TemplateTypeParmTypeBitfields {
2138
+ friend class TemplateTypeParmType ;
2139
+
2140
+ LLVM_PREFERRED_TYPE (TypeBitfields)
2141
+ unsigned : NumTypeBits;
2142
+
2143
+ // / The depth of the template parameter.
2144
+ unsigned Depth : 15 ;
2145
+
2146
+ // / Whether this is a template parameter pack.
2147
+ LLVM_PREFERRED_TYPE (bool )
2148
+ unsigned ParameterPack : 1 ;
2149
+
2150
+ // / The index of the template parameter.
2151
+ unsigned Index : 16 ;
2152
+ };
2153
+
2137
2154
class SubstTemplateTypeParmTypeBitfields {
2138
2155
friend class SubstTemplateTypeParmType ;
2139
2156
@@ -2257,6 +2274,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
2257
2274
TypeWithKeywordBitfields TypeWithKeywordBits;
2258
2275
ElaboratedTypeBitfields ElaboratedTypeBits;
2259
2276
VectorTypeBitfields VectorTypeBits;
2277
+ TemplateTypeParmTypeBitfields TemplateTypeParmTypeBits;
2260
2278
SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits;
2261
2279
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits;
2262
2280
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
@@ -6135,52 +6153,30 @@ class BTFTagAttributedType : public Type, public llvm::FoldingSetNode {
6135
6153
class TemplateTypeParmType : public Type , public llvm ::FoldingSetNode {
6136
6154
friend class ASTContext ; // ASTContext creates these
6137
6155
6138
- // Helper data collector for canonical types.
6139
- struct CanonicalTTPTInfo {
6140
- unsigned Depth : 15 ;
6141
- unsigned ParameterPack : 1 ;
6142
- unsigned Index : 16 ;
6143
- };
6144
-
6145
- union {
6146
- // Info for the canonical type.
6147
- CanonicalTTPTInfo CanTTPTInfo;
6148
-
6149
- // Info for the non-canonical type.
6150
- TemplateTypeParmDecl *TTPDecl;
6151
- };
6156
+ // The associated TemplateTypeParmDecl for the non-canonical type.
6157
+ TemplateTypeParmDecl *TTPDecl;
6152
6158
6153
- // / Build a non-canonical type.
6154
- TemplateTypeParmType ( TemplateTypeParmDecl *TTPDecl, QualType Canon)
6159
+ TemplateTypeParmType ( unsigned D, unsigned I, bool PP,
6160
+ TemplateTypeParmDecl *TTPDecl, QualType Canon)
6155
6161
: Type(TemplateTypeParm, Canon,
6156
6162
TypeDependence::DependentInstantiation |
6157
- (Canon->getDependence () & TypeDependence::UnexpandedPack)),
6158
- TTPDecl(TTPDecl) {}
6159
-
6160
- // / Build the canonical type.
6161
- TemplateTypeParmType (unsigned D, unsigned I, bool PP)
6162
- : Type(TemplateTypeParm, QualType(this , 0 ),
6163
- TypeDependence::DependentInstantiation |
6164
- (PP ? TypeDependence::UnexpandedPack : TypeDependence::None)) {
6165
- CanTTPTInfo.Depth = D;
6166
- CanTTPTInfo.Index = I;
6167
- CanTTPTInfo.ParameterPack = PP;
6168
- }
6169
-
6170
- const CanonicalTTPTInfo& getCanTTPTInfo () const {
6171
- QualType Can = getCanonicalTypeInternal ();
6172
- return Can->castAs <TemplateTypeParmType>()->CanTTPTInfo ;
6163
+ (PP ? TypeDependence::UnexpandedPack : TypeDependence::None)),
6164
+ TTPDecl (TTPDecl) {
6165
+ assert (!TTPDecl == Canon.isNull ());
6166
+ TemplateTypeParmTypeBits.Depth = D;
6167
+ TemplateTypeParmTypeBits.Index = I;
6168
+ TemplateTypeParmTypeBits.ParameterPack = PP;
6173
6169
}
6174
6170
6175
6171
public:
6176
- unsigned getDepth () const { return getCanTTPTInfo ().Depth ; }
6177
- unsigned getIndex () const { return getCanTTPTInfo ().Index ; }
6178
- bool isParameterPack () const { return getCanTTPTInfo ().ParameterPack ; }
6179
-
6180
- TemplateTypeParmDecl *getDecl () const {
6181
- return isCanonicalUnqualified () ? nullptr : TTPDecl;
6172
+ unsigned getDepth () const { return TemplateTypeParmTypeBits.Depth ; }
6173
+ unsigned getIndex () const { return TemplateTypeParmTypeBits.Index ; }
6174
+ bool isParameterPack () const {
6175
+ return TemplateTypeParmTypeBits.ParameterPack ;
6182
6176
}
6183
6177
6178
+ TemplateTypeParmDecl *getDecl () const { return TTPDecl; }
6179
+
6184
6180
IdentifierInfo *getIdentifier () const ;
6185
6181
6186
6182
bool isSugared () const { return false ; }
0 commit comments