@@ -51,6 +51,7 @@ template <> struct PointerLikeTypeTraits<clang::Expr *> {
51
51
52
52
namespace clang {
53
53
54
+ class APValue ;
54
55
class ASTContext ;
55
56
class DiagnosticBuilder ;
56
57
class Expr ;
@@ -82,6 +83,12 @@ class TemplateArgument {
82
83
// / that was provided for an integral non-type template parameter.
83
84
Integral,
84
85
86
+ // / The template argument is a non-type template argument that can't be
87
+ // / represented by the special-case Declaration, NullPtr, or Integral
88
+ // / forms. These values are only ever produced by constant evaluation,
89
+ // / so cannot be dependent.
90
+ UncommonValue,
91
+
85
92
// / The template argument is a template name that was provided for a
86
93
// / template template parameter.
87
94
Template,
@@ -125,6 +132,11 @@ class TemplateArgument {
125
132
};
126
133
void *Type;
127
134
};
135
+ struct V {
136
+ unsigned Kind;
137
+ const APValue *Value;
138
+ void *Type;
139
+ };
128
140
struct A {
129
141
unsigned Kind;
130
142
unsigned NumArgs;
@@ -142,6 +154,7 @@ class TemplateArgument {
142
154
union {
143
155
struct DA DeclArg;
144
156
struct I Integer;
157
+ struct V Value;
145
158
struct A Args;
146
159
struct TA TemplateArg;
147
160
struct TV TypeOrValue;
@@ -157,9 +170,8 @@ class TemplateArgument {
157
170
TypeOrValue.V = reinterpret_cast <uintptr_t >(T.getAsOpaquePtr ());
158
171
}
159
172
160
- // / Construct a template argument that refers to a
161
- // / declaration, which is either an external declaration or a
162
- // / template declaration.
173
+ // / Construct a template argument that refers to a (non-dependent)
174
+ // / declaration.
163
175
TemplateArgument (ValueDecl *D, QualType QT) {
164
176
assert (D && " Expected decl" );
165
177
DeclArg.Kind = Declaration;
@@ -169,7 +181,11 @@ class TemplateArgument {
169
181
170
182
// / Construct an integral constant template argument. The memory to
171
183
// / store the value is allocated with Ctx.
172
- TemplateArgument (ASTContext &Ctx, const llvm::APSInt &Value, QualType Type);
184
+ TemplateArgument (const ASTContext &Ctx, const llvm::APSInt &Value,
185
+ QualType Type);
186
+
187
+ // / Construct a template argument from an arbitrary constant value.
188
+ TemplateArgument (const ASTContext &Ctx, QualType Type, const APValue &Value);
173
189
174
190
// / Construct an integral constant template argument with the same
175
191
// / value as Other but a different type.
@@ -340,6 +356,16 @@ class TemplateArgument {
340
356
Integer.Type = T.getAsOpaquePtr ();
341
357
}
342
358
359
+ // / Get the value of an UncommonValue.
360
+ const APValue &getAsUncommonValue () const {
361
+ return *Value.Value ;
362
+ }
363
+
364
+ // / Get the type of an UncommonValue.
365
+ QualType getUncommonValueType () const {
366
+ return QualType::getFromOpaquePtr (Value.Type );
367
+ }
368
+
343
369
// / If this is a non-type template argument, get its type. Otherwise,
344
370
// / returns a null QualType.
345
371
QualType getNonTypeTemplateArgumentType () const ;
@@ -484,6 +510,7 @@ class TemplateArgumentLoc {
484
510
assert (Argument.getKind () == TemplateArgument::NullPtr ||
485
511
Argument.getKind () == TemplateArgument::Integral ||
486
512
Argument.getKind () == TemplateArgument::Declaration ||
513
+ Argument.getKind () == TemplateArgument::UncommonValue ||
487
514
Argument.getKind () == TemplateArgument::Expression);
488
515
}
489
516
@@ -542,6 +569,11 @@ class TemplateArgumentLoc {
542
569
return LocInfo.getAsExpr ();
543
570
}
544
571
572
+ Expr *getSourceUncommonValueExpression () const {
573
+ assert (Argument.getKind () == TemplateArgument::UncommonValue);
574
+ return LocInfo.getAsExpr ();
575
+ }
576
+
545
577
NestedNameSpecifierLoc getTemplateQualifierLoc () const {
546
578
if (Argument.getKind () != TemplateArgument::Template &&
547
579
Argument.getKind () != TemplateArgument::TemplateExpansion)
0 commit comments