@@ -111,6 +111,14 @@ struct TypeInfo
111111 */
112112 bool IsPackExpansion = false ;
113113
114+ /* * The const qualifier
115+ */
116+ bool IsConst = false ;
117+
118+ /* * The volatile qualifier
119+ */
120+ bool IsVolatile = false ;
121+
114122 /* * The constraints associated with the type
115123
116124 This represents the constraints associated with the type,
@@ -135,25 +143,6 @@ struct TypeInfo
135143 constexpr bool isArray () const noexcept { return Kind == TypeKind::Array; }
136144 constexpr bool isFunction () const noexcept { return Kind == TypeKind::Function; }
137145
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-
157146 /* * Return the symbol named by this type.
158147 */
159148 SymbolID
@@ -222,7 +211,6 @@ struct TypeInfoCommonBase : TypeInfo
222211struct NamedTypeInfo final
223212 : TypeInfoCommonBase<TypeKind::Named>
224213{
225- QualifierKind CVQualifiers = QualifierKind::None;
226214 Polymorphic<NameInfo> Name;
227215
228216 std::strong_ordering
@@ -232,7 +220,6 @@ struct NamedTypeInfo final
232220struct DecltypeTypeInfo final
233221 : TypeInfoCommonBase<TypeKind::Decltype>
234222{
235- QualifierKind CVQualifiers = QualifierKind::None;
236223 ExprInfo Operand;
237224
238225 auto operator <=>(DecltypeTypeInfo const &) const = default ;
@@ -241,7 +228,6 @@ struct DecltypeTypeInfo final
241228struct AutoTypeInfo final
242229 : TypeInfoCommonBase<TypeKind::Auto>
243230{
244- QualifierKind CVQualifiers = QualifierKind::None;
245231 AutoKind Keyword = AutoKind::Auto;
246232 Polymorphic<NameInfo> Constraint;
247233
@@ -254,12 +240,6 @@ struct LValueReferenceTypeInfo final
254240{
255241 Polymorphic<TypeInfo> PointeeType;
256242
257- TypeInfo*
258- innerType () noexcept override
259- {
260- return PointeeType.operator ->();
261- }
262-
263243 std::strong_ordering
264244 operator <=>(LValueReferenceTypeInfo const &) const ;
265245};
@@ -269,46 +249,25 @@ struct RValueReferenceTypeInfo final
269249{
270250 Polymorphic<TypeInfo> PointeeType;
271251
272- TypeInfo*
273- innerType () noexcept override
274- {
275- return PointeeType.operator ->();
276- }
277-
278252 std::strong_ordering
279253 operator <=>(RValueReferenceTypeInfo const &) const ;
280254};
281255
282256struct PointerTypeInfo final
283257 : TypeInfoCommonBase<TypeKind::Pointer>
284258{
285- QualifierKind CVQualifiers = QualifierKind::None;
286259 Polymorphic<TypeInfo> PointeeType;
287260
288- TypeInfo*
289- innerType () noexcept override
290- {
291- return PointeeType.operator ->();
292- }
293-
294261 std::strong_ordering
295262 operator <=>(PointerTypeInfo const &) const ;
296263};
297264
298265struct MemberPointerTypeInfo final
299266 : TypeInfoCommonBase<TypeKind::MemberPointer>
300267{
301- QualifierKind CVQualifiers = QualifierKind::None;
302268 Polymorphic<TypeInfo> ParentType;
303269 Polymorphic<TypeInfo> PointeeType;
304270
305- TypeInfo*
306- innerType () noexcept override
307- {
308- return PointeeType.operator ->();
309- }
310-
311-
312271 std::strong_ordering
313272 operator <=>(MemberPointerTypeInfo const &) const ;
314273};
@@ -319,12 +278,6 @@ struct ArrayTypeInfo final
319278 Polymorphic<TypeInfo> ElementType;
320279 ConstantExprInfo<std::uint64_t > Bounds;
321280
322- TypeInfo*
323- innerType () noexcept override
324- {
325- return ElementType.operator ->();
326- }
327-
328281 std::strong_ordering
329282 operator <=>(ArrayTypeInfo const &) const ;
330283};
@@ -334,17 +287,10 @@ struct FunctionTypeInfo final
334287{
335288 Polymorphic<TypeInfo> ReturnType;
336289 std::vector<Polymorphic<TypeInfo>> ParamTypes;
337- QualifierKind CVQualifiers = QualifierKind::None;
338290 ReferenceKind RefQualifier = ReferenceKind::None;
339291 NoexceptInfo ExceptionSpec;
340292 bool IsVariadic = false ;
341293
342- TypeInfo*
343- innerType () noexcept override
344- {
345- return ReturnType.operator ->();
346- }
347-
348294 std::strong_ordering
349295 operator <=>(FunctionTypeInfo const &) const ;
350296};
@@ -413,6 +359,44 @@ operator==(Polymorphic<TypeInfo> const& lhs, Polymorphic<TypeInfo> const& rhs) {
413359 return lhs <=> rhs == std::strong_ordering::equal;
414360}
415361
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 ;
416400
417401// VFALCO maybe we should rename this to `renderType` or something?
418402MRDOCS_DECL
0 commit comments