@@ -111,6 +111,14 @@ struct TypeInfo
111
111
*/
112
112
bool IsPackExpansion = false ;
113
113
114
+ /* * The const qualifier
115
+ */
116
+ bool IsConst = false ;
117
+
118
+ /* * The volatile qualifier
119
+ */
120
+ bool IsVolatile = false ;
121
+
114
122
/* * The constraints associated with the type
115
123
116
124
This represents the constraints associated with the type,
@@ -135,25 +143,6 @@ struct TypeInfo
135
143
constexpr bool isArray () const noexcept { return Kind == TypeKind::Array; }
136
144
constexpr bool isFunction () const noexcept { return Kind == TypeKind::Function; }
137
145
138
- /* * Return the inner type.
139
-
140
- The inner type is the type which is modified
141
- by a specifier (e.g. "int" in "pointer to int".
142
- */
143
- virtual
144
- TypeInfo*
145
- innerType () noexcept
146
- {
147
- return nullptr ;
148
- }
149
-
150
- virtual
151
- TypeInfo const *
152
- cInnerType () const noexcept
153
- {
154
- return const_cast <TypeInfo*>(this )->innerType ();
155
- }
156
-
157
146
/* * Return the symbol named by this type.
158
147
*/
159
148
SymbolID
@@ -222,7 +211,6 @@ struct TypeInfoCommonBase : TypeInfo
222
211
struct NamedTypeInfo final
223
212
: TypeInfoCommonBase<TypeKind::Named>
224
213
{
225
- QualifierKind CVQualifiers = QualifierKind::None;
226
214
Polymorphic<NameInfo> Name;
227
215
228
216
std::strong_ordering
@@ -232,7 +220,6 @@ struct NamedTypeInfo final
232
220
struct DecltypeTypeInfo final
233
221
: TypeInfoCommonBase<TypeKind::Decltype>
234
222
{
235
- QualifierKind CVQualifiers = QualifierKind::None;
236
223
ExprInfo Operand;
237
224
238
225
auto operator <=>(DecltypeTypeInfo const &) const = default ;
@@ -241,7 +228,6 @@ struct DecltypeTypeInfo final
241
228
struct AutoTypeInfo final
242
229
: TypeInfoCommonBase<TypeKind::Auto>
243
230
{
244
- QualifierKind CVQualifiers = QualifierKind::None;
245
231
AutoKind Keyword = AutoKind::Auto;
246
232
Polymorphic<NameInfo> Constraint;
247
233
@@ -254,12 +240,6 @@ struct LValueReferenceTypeInfo final
254
240
{
255
241
Polymorphic<TypeInfo> PointeeType;
256
242
257
- TypeInfo*
258
- innerType () noexcept override
259
- {
260
- return PointeeType.operator ->();
261
- }
262
-
263
243
std::strong_ordering
264
244
operator <=>(LValueReferenceTypeInfo const &) const ;
265
245
};
@@ -269,46 +249,25 @@ struct RValueReferenceTypeInfo final
269
249
{
270
250
Polymorphic<TypeInfo> PointeeType;
271
251
272
- TypeInfo*
273
- innerType () noexcept override
274
- {
275
- return PointeeType.operator ->();
276
- }
277
-
278
252
std::strong_ordering
279
253
operator <=>(RValueReferenceTypeInfo const &) const ;
280
254
};
281
255
282
256
struct PointerTypeInfo final
283
257
: TypeInfoCommonBase<TypeKind::Pointer>
284
258
{
285
- QualifierKind CVQualifiers = QualifierKind::None;
286
259
Polymorphic<TypeInfo> PointeeType;
287
260
288
- TypeInfo*
289
- innerType () noexcept override
290
- {
291
- return PointeeType.operator ->();
292
- }
293
-
294
261
std::strong_ordering
295
262
operator <=>(PointerTypeInfo const &) const ;
296
263
};
297
264
298
265
struct MemberPointerTypeInfo final
299
266
: TypeInfoCommonBase<TypeKind::MemberPointer>
300
267
{
301
- QualifierKind CVQualifiers = QualifierKind::None;
302
268
Polymorphic<TypeInfo> ParentType;
303
269
Polymorphic<TypeInfo> PointeeType;
304
270
305
- TypeInfo*
306
- innerType () noexcept override
307
- {
308
- return PointeeType.operator ->();
309
- }
310
-
311
-
312
271
std::strong_ordering
313
272
operator <=>(MemberPointerTypeInfo const &) const ;
314
273
};
@@ -319,12 +278,6 @@ struct ArrayTypeInfo final
319
278
Polymorphic<TypeInfo> ElementType;
320
279
ConstantExprInfo<std::uint64_t > Bounds;
321
280
322
- TypeInfo*
323
- innerType () noexcept override
324
- {
325
- return ElementType.operator ->();
326
- }
327
-
328
281
std::strong_ordering
329
282
operator <=>(ArrayTypeInfo const &) const ;
330
283
};
@@ -334,17 +287,10 @@ struct FunctionTypeInfo final
334
287
{
335
288
Polymorphic<TypeInfo> ReturnType;
336
289
std::vector<Polymorphic<TypeInfo>> ParamTypes;
337
- QualifierKind CVQualifiers = QualifierKind::None;
338
290
ReferenceKind RefQualifier = ReferenceKind::None;
339
291
NoexceptInfo ExceptionSpec;
340
292
bool IsVariadic = false ;
341
293
342
- TypeInfo*
343
- innerType () noexcept override
344
- {
345
- return ReturnType.operator ->();
346
- }
347
-
348
294
std::strong_ordering
349
295
operator <=>(FunctionTypeInfo const &) const ;
350
296
};
@@ -413,6 +359,44 @@ operator==(Polymorphic<TypeInfo> const& lhs, Polymorphic<TypeInfo> const& rhs) {
413
359
return lhs <=> rhs == std::strong_ordering::equal;
414
360
}
415
361
362
+ /* * Return the inner type.
363
+
364
+ The inner type is the type which is modified
365
+ by a specifier (e.g. "int" in "pointer to int".
366
+ */
367
+ MRDOCS_DECL
368
+ std::optional<std::reference_wrapper<Polymorphic<TypeInfo> const >>
369
+ innerType (TypeInfo const & TI) noexcept ;
370
+
371
+ // / @copydoc innerType(TypeInfo const&)
372
+ MRDOCS_DECL
373
+ std::optional<std::reference_wrapper<Polymorphic<TypeInfo>>>
374
+ innerType (TypeInfo& TI) noexcept ;
375
+
376
+ // / @copydoc innerType(TypeInfo const&)
377
+ MRDOCS_DECL
378
+ TypeInfo const *
379
+ innerTypePtr (TypeInfo const & TI) noexcept ;
380
+
381
+ // / @copydoc innerTypePtr(TypeInfo const&)
382
+ MRDOCS_DECL
383
+ TypeInfo*
384
+ innerTypePtr (TypeInfo& TI) noexcept ;
385
+
386
+ /* * Return the innermost type.
387
+
388
+ The innermost type is the type which is not
389
+ modified by any specifiers (e.g. "int" in
390
+ "pointer to const int").
391
+ */
392
+ MRDOCS_DECL
393
+ std::optional<std::reference_wrapper<Polymorphic<TypeInfo> const >>
394
+ innermostType (TypeInfo const & TI) noexcept ;
395
+
396
+ // / @copydoc innermostType(TypeInfo const&)
397
+ MRDOCS_DECL
398
+ std::optional<std::reference_wrapper<Polymorphic<TypeInfo>>>
399
+ innermostType (TypeInfo& TI) noexcept ;
416
400
417
401
// VFALCO maybe we should rename this to `renderType` or something?
418
402
MRDOCS_DECL
0 commit comments