@@ -113,22 +113,18 @@ class TemplateArgument {
113
113
struct DA {
114
114
LLVM_PREFERRED_TYPE (ArgKind)
115
115
unsigned Kind : 31 ;
116
- LLVM_PREFERRED_TYPE (bool )
117
- unsigned IsDefaulted : 1 ;
118
116
void *QT;
119
117
ValueDecl *D;
120
118
};
121
119
struct I {
122
120
LLVM_PREFERRED_TYPE (ArgKind)
123
121
unsigned Kind : 31 ;
124
122
LLVM_PREFERRED_TYPE (bool )
125
- unsigned IsDefaulted : 1 ;
123
+ unsigned IsUnsigned : 1 ;
126
124
// We store a decomposed APSInt with the data allocated by ASTContext if
127
125
// BitWidth > 64. The memory may be shared between multiple
128
126
// TemplateArgument instances.
129
127
unsigned BitWidth : 31 ;
130
- LLVM_PREFERRED_TYPE (bool )
131
- unsigned IsUnsigned : 1 ;
132
128
union {
133
129
// / Used to store the <= 64 bits integer value.
134
130
uint64_t VAL;
@@ -141,33 +137,25 @@ class TemplateArgument {
141
137
struct V {
142
138
LLVM_PREFERRED_TYPE (ArgKind)
143
139
unsigned Kind : 31 ;
144
- LLVM_PREFERRED_TYPE (bool )
145
- unsigned IsDefaulted : 1 ;
146
140
APValue *Value;
147
141
void *Type;
148
142
};
149
143
struct A {
150
144
LLVM_PREFERRED_TYPE (ArgKind)
151
145
unsigned Kind : 31 ;
152
- LLVM_PREFERRED_TYPE (bool )
153
- unsigned IsDefaulted : 1 ;
154
146
unsigned NumArgs;
155
147
const TemplateArgument *Args;
156
148
};
157
149
struct TA {
158
150
LLVM_PREFERRED_TYPE (ArgKind)
159
151
unsigned Kind : 31 ;
160
- LLVM_PREFERRED_TYPE (bool )
161
- unsigned IsDefaulted : 1 ;
162
152
UnsignedOrNone NumExpansions;
163
153
void *Name;
164
154
};
165
155
struct TV {
166
156
LLVM_PREFERRED_TYPE (ArgKind)
167
157
unsigned Kind : 31 ;
168
158
LLVM_PREFERRED_TYPE (bool )
169
- unsigned IsDefaulted : 1 ;
170
- LLVM_PREFERRED_TYPE (bool )
171
159
unsigned IsCanonicalExpr : 1 ;
172
160
uintptr_t V;
173
161
};
@@ -180,38 +168,46 @@ class TemplateArgument {
180
168
struct TV TypeOrValue;
181
169
};
182
170
183
- void initFromType (QualType T, bool IsNullPtr, bool IsDefaulted);
184
- void initFromDeclaration (ValueDecl *D, QualType QT, bool IsDefaulted);
171
+ void initFromType (QualType T, bool IsNullPtr) {
172
+ TypeOrValue.Kind = IsNullPtr ? NullPtr : Type;
173
+ TypeOrValue.V = reinterpret_cast <uintptr_t >(T.getAsOpaquePtr ());
174
+ }
175
+
176
+ void initFromDeclaration (ValueDecl *D, QualType QT) {
177
+ assert (D && " Expected decl" );
178
+ DeclArg.Kind = Declaration;
179
+ DeclArg.QT = QT.getAsOpaquePtr ();
180
+ DeclArg.D = D;
181
+ }
182
+
185
183
void initFromIntegral (const ASTContext &Ctx, const llvm::APSInt &Value,
186
- QualType Type, bool IsDefaulted );
184
+ QualType Type);
187
185
void initFromStructural (const ASTContext &Ctx, QualType Type,
188
- const APValue &V, bool IsDefaulted );
186
+ const APValue &V);
189
187
190
188
public:
191
189
// / Construct an empty, invalid template argument.
192
190
constexpr TemplateArgument ()
193
- : TypeOrValue{Null, /* IsDefaulted= */ 0 , /* IsCanonicalExpr=*/ 0 , /* V=*/ 0 } {}
191
+ : TypeOrValue{Null, /* IsCanonicalExpr=*/ false , /* V=*/ 0 } {}
194
192
195
193
// / Construct a template type argument.
196
- TemplateArgument (QualType T, bool isNullPtr = false ,
197
- bool IsDefaulted = false ) {
198
- initFromType (T, isNullPtr, IsDefaulted);
194
+ TemplateArgument (QualType T, bool isNullPtr = false ) {
195
+ initFromType (T, isNullPtr);
199
196
}
200
197
201
198
// / Construct a template argument that refers to a (non-dependent)
202
199
// / declaration.
203
- TemplateArgument (ValueDecl *D, QualType QT, bool IsDefaulted = false ) {
204
- initFromDeclaration (D, QT, IsDefaulted);
205
- }
200
+ TemplateArgument (ValueDecl *D, QualType QT) { initFromDeclaration (D, QT); }
206
201
207
202
// / Construct an integral constant template argument. The memory to
208
203
// / store the value is allocated with Ctx.
209
204
TemplateArgument (const ASTContext &Ctx, const llvm::APSInt &Value,
210
- QualType Type, bool IsDefaulted = false );
205
+ QualType Type) {
206
+ initFromIntegral (Ctx, Value, Type);
207
+ }
211
208
212
209
// / Construct a template argument from an arbitrary constant value.
213
- TemplateArgument (const ASTContext &Ctx, QualType Type, const APValue &Value,
214
- bool IsDefaulted = false );
210
+ TemplateArgument (const ASTContext &Ctx, QualType Type, const APValue &Value);
215
211
216
212
// / Construct an integral constant template argument with the same
217
213
// / value as Other but a different type.
@@ -228,12 +224,8 @@ class TemplateArgument {
228
224
// / is taken.
229
225
// /
230
226
// / \param Name The template name.
231
- // /
232
- // / \param IsDefaulted If 'true', implies that this TemplateArgument
233
- // / corresponds to a default template parameter
234
- TemplateArgument (TemplateName Name, bool IsDefaulted = false ) {
227
+ TemplateArgument (TemplateName Name) {
235
228
TemplateArg.Kind = Template;
236
- TemplateArg.IsDefaulted = IsDefaulted;
237
229
TemplateArg.Name = Name.getAsVoidPointer ();
238
230
TemplateArg.NumExpansions = std::nullopt;
239
231
}
@@ -249,13 +241,8 @@ class TemplateArgument {
249
241
// /
250
242
// / \param NumExpansions The number of expansions that will be generated by
251
243
// / instantiating
252
- // /
253
- // / \param IsDefaulted If 'true', implies that this TemplateArgument
254
- // / corresponds to a default template parameter
255
- TemplateArgument (TemplateName Name, UnsignedOrNone NumExpansions,
256
- bool IsDefaulted = false ) {
244
+ TemplateArgument (TemplateName Name, UnsignedOrNone NumExpansions) {
257
245
TemplateArg.Kind = TemplateExpansion;
258
- TemplateArg.IsDefaulted = IsDefaulted;
259
246
TemplateArg.Name = Name.getAsVoidPointer ();
260
247
TemplateArg.NumExpansions = NumExpansions;
261
248
}
@@ -265,9 +252,8 @@ class TemplateArgument {
265
252
// / This form of template argument only occurs in template argument
266
253
// / lists used for dependent types and for expression; it will not
267
254
// / occur in a non-dependent, canonical template argument list.
268
- TemplateArgument (Expr *E, bool IsCanonical, bool IsDefaulted = false ) {
255
+ TemplateArgument (Expr *E, bool IsCanonical) {
269
256
TypeOrValue.Kind = Expression;
270
- TypeOrValue.IsDefaulted = IsDefaulted;
271
257
TypeOrValue.IsCanonicalExpr = IsCanonical;
272
258
TypeOrValue.V = reinterpret_cast <uintptr_t >(E);
273
259
}
@@ -278,7 +264,6 @@ class TemplateArgument {
278
264
// / outlives the TemplateArgument itself.
279
265
explicit TemplateArgument (ArrayRef<TemplateArgument> Args) {
280
266
this ->Args .Kind = Pack;
281
- this ->Args .IsDefaulted = false ;
282
267
this ->Args .Args = Args.data ();
283
268
this ->Args .NumArgs = Args.size ();
284
269
}
@@ -387,14 +372,6 @@ class TemplateArgument {
387
372
Integer.Type = T.getAsOpaquePtr ();
388
373
}
389
374
390
- // / Set to 'true' if this TemplateArgument corresponds to a
391
- // / default template parameter.
392
- void setIsDefaulted (bool v) { TypeOrValue.IsDefaulted = v; }
393
-
394
- // / If returns 'true', this TemplateArgument corresponds to a
395
- // / default template parameter.
396
- bool getIsDefaulted () const { return (bool )TypeOrValue.IsDefaulted ; }
397
-
398
375
// / Get the value of a StructuralValue.
399
376
const APValue &getAsStructuralValue () const { return *Value.Value ; }
400
377
0 commit comments