diff --git a/include/ifc/abstract-sgraph.hxx b/include/ifc/abstract-sgraph.hxx index d6f8c47..c9e31d3 100644 --- a/include/ifc/abstract-sgraph.hxx +++ b/include/ifc/abstract-sgraph.hxx @@ -562,7 +562,7 @@ namespace ifc { // (really an associative map of declarations to values) SumTypeValue, // The representation of a union object value expression tree. // Unions have a single active SubobjectValue - SubobjectValue, // A key-value pair under a ProductTypeValue + UnusedSort1, // Empty slot. ArrayValue, // A constant-initialized array value object DynamicDispatch, // A dynamic dispatch expression, i.e. call to virtual function VirtualFunctionConversion, // A conversion of a virtual function reference to its underlying target: C::f // 'f' @@ -758,30 +758,22 @@ namespace ifc { }; struct TemplateName : Tag { - TemplateName() : name{} {} - TemplateName(NameIndex x) : name{x} {} - NameIndex name; // template name; can't be itself another TemplateName. + NameIndex name{}; // template name; can't be itself another TemplateName. bool operator==(const TemplateName&) const = default; }; struct SpecializationName : Tag { - SpecializationName() : primary_template{}, arguments{} {} - SpecializationName(NameIndex primary_template, ExprIndex arguments) - : primary_template{primary_template}, arguments{arguments} - {} - NameIndex primary_template; // The primary template name. Note: NameIndex is over-generic here. E.g. it - // can't be a decltype, nor can it be another template-id. - ExprIndex arguments; + NameIndex primary_template{}; // The primary template name. Note: NameIndex is over-generic here. E.g. it + // can't be a decltype, nor can it be another template-id. + ExprIndex arguments{}; bool operator==(const SpecializationName&) const = default; }; struct SourceFileName : Tag { - SourceFileName() : name{}, include_guard{} {} - SourceFileName(TextOffset name, TextOffset include_guard) : name{name}, include_guard{include_guard} {} - TextOffset name; - TextOffset include_guard; + TextOffset name{}; + TextOffset include_guard{}; bool operator==(const SourceFileName&) const = default; }; @@ -846,10 +838,6 @@ namespace ifc { bool operator==(const NoexceptSpecification&) const = default; }; - struct UnaryTypeCtorInstance { - TypeIndex operand; - }; - // The set of fundamental type basis. enum class TypeBasis : uint8_t { Void, // "void" @@ -903,11 +891,9 @@ namespace ifc { // They are represented externally as possibly signed variation of a core basis // of builtin types, with versions expressing "bitness". struct FundamentalType : Tag { - FundamentalType() : basis{}, precision{}, sign{} {} - FundamentalType(TypeBasis b, TypePrecision p, TypeSign s) : basis{b}, precision{p}, sign{s} {} - TypeBasis basis; - TypePrecision precision; - TypeSign sign; + TypeBasis basis{}; + TypePrecision precision{}; + TypeSign sign{}; uint8_t unused{}; }; @@ -919,75 +905,45 @@ namespace ifc { // Designation of a type by a declared name. struct DesignatedType : Tag { - DesignatedType() : decl{} {} - DesignatedType(DeclIndex idx) : decl{idx} {} - DeclIndex decl; // A declaration for this type. + DeclIndex decl{}; // A declaration for the entity designated by type. }; struct TorType : Tag { - TypeIndex source; // Parameter type sequence. - NoexceptSpecification eh_spec; // Noexcept specification. - CallingConvention convention; // Calling convention. + TypeIndex source{}; // Parameter type sequence. + NoexceptSpecification eh_spec{}; // Noexcept specification. + CallingConvention convention{}; // Calling convention. bool operator==(const TorType&) const = default; }; struct SyntacticType : Tag { - SyntacticType() : expr{} {} - SyntacticType(ExprIndex x) : expr{x} {} - ExprIndex expr; + ExprIndex expr{}; }; // Type-id expansion involving a template parameter pack. struct ExpansionType : Tag { - ExpansionType() = default; - ExpansionType(TypeIndex t, ExpansionMode m) : operand{t}, mode{m} {} - TypeIndex operand = {}; + TypeIndex pack = {}; ExpansionMode mode = {}; }; // Pointer type. - struct PointerType : Tag, UnaryTypeCtorInstance { - PointerType() : UnaryTypeCtorInstance{} {} - PointerType(TypeIndex t) : UnaryTypeCtorInstance{t} {} - - TypeIndex pointee() const - { - return operand; - } + struct PointerType : Tag { + TypeIndex pointee{}; }; // Lvalue reference type. - struct LvalueReferenceType : Tag, UnaryTypeCtorInstance { - LvalueReferenceType() : UnaryTypeCtorInstance{} {} - LvalueReferenceType(TypeIndex t) : UnaryTypeCtorInstance{t} {} - - TypeIndex referee() const - { - return operand; - } + struct LvalueReferenceType : Tag { + TypeIndex referee{}; }; // Rvalue reference type. - struct RvalueReferenceType : Tag, UnaryTypeCtorInstance { - RvalueReferenceType() : UnaryTypeCtorInstance{} {} - RvalueReferenceType(TypeIndex t) : UnaryTypeCtorInstance{t} {} - - TypeIndex referee() const - { - return operand; - } + struct RvalueReferenceType : Tag { + TypeIndex referee{}; }; // Unaligned type -- an MS VC curiosity. - struct UnalignedType : Tag, UnaryTypeCtorInstance { - UnalignedType() : UnaryTypeCtorInstance{} {} - UnalignedType(TypeIndex t) : UnaryTypeCtorInstance{t} {} - - TypeIndex type() const - { - return operand; - } + struct UnalignedType : Tag { + TypeIndex operand{}; }; struct DecltypeType : Tag { @@ -995,15 +951,13 @@ namespace ifc { }; struct PlaceholderType : Tag { - ExprIndex constraint; // The predicate associated with this type placeholder. Null means no constraint. - TypeBasis basis; // auto/decltype(auto) - TypeIndex elaboration; // The type this placeholder was deduced to. + ExprIndex constraint{}; // The predicate associated with this type placeholder. Null means no constraint. + TypeBasis basis{}; // auto/decltype(auto) + TypeIndex elaboration{}; // The type this placeholder was deduced to. }; // A pointer to non-static member type. struct PointerToMemberType : Tag { - PointerToMemberType() = default; - PointerToMemberType(TypeIndex s, TypeIndex t) : scope{s}, type{t} {} TypeIndex scope = {}; // The enclosing class TypeIndex type = {}; // Type of the pointed-to member. }; @@ -1030,51 +984,44 @@ namespace ifc { // is not modelled as overload resolution (because it is not). Rather it is predicate // refinement/subsumption, and as such does not belong (int the current design) in the type. struct ForallType : Tag { - ForallType(ChartIndex c, TypeIndex t) : chart{c}, subject{t} {} - ChartIndex chart; // The set of parameters of this parametric type - TypeIndex subject; // The type being parameterized + ChartIndex chart{}; // The set of parameters of this parametric type + TypeIndex subject{}; // The type being parameterized }; // Ordinary function types struct FunctionType : Tag { - TypeIndex target; // result type - TypeIndex source; // Description of parameter types. - NoexceptSpecification eh_spec; // Noexcept specification. - CallingConvention convention; // Calling convention. - FunctionTypeTraits traits; // Various (rare) function-type traits + TypeIndex target{}; // result type + TypeIndex source{}; // Description of parameter types. + NoexceptSpecification eh_spec{}; // Noexcept specification. + CallingConvention convention{}; // Calling convention. + FunctionTypeTraits traits{}; // Various (rare) function-type traits }; // Non-static member function types. struct MethodType : Tag { - TypeIndex target; // result type - TypeIndex source; // Description of parameter types. - TypeIndex class_type; // The enclosing class associated with this non-static member function type - NoexceptSpecification eh_spec; // Noexcept specification. - CallingConvention convention; // Calling convention. - FunctionTypeTraits traits; // Various (rare) function-type traits + TypeIndex target{}; // result type + TypeIndex source{}; // Description of parameter types. + TypeIndex class_type{}; // The enclosing class associated with this non-static member function type + NoexceptSpecification eh_spec{}; // Noexcept specification. + CallingConvention convention{}; // Calling convention. + FunctionTypeTraits traits{}; // Various (rare) function-type traits }; // Builtin array types. struct ArrayType : Tag { - ArrayType() = default; - ArrayType(TypeIndex t, ExprIndex n) : element{t}, bound{n} {} TypeIndex element = {}; // The array element type. ExprIndex bound = {}; // The number of element in this array. }; // Qualified types: struct QualifiedType : Tag { - QualifiedType() = default; - QualifiedType(TypeIndex t, Qualifier q) : unqualified_type{t}, qualifiers{q} {} TypeIndex unqualified_type = {}; Qualifier qualifiers = {}; }; // Unresolved type names. struct TypenameType : Tag { - TypenameType() : path{} {} - TypenameType(ExprIndex x) : path{x} {} - ExprIndex path; + ExprIndex path{}; }; enum class BaseClassTraits : uint8_t { @@ -1085,9 +1032,9 @@ namespace ifc { // Base-type in a class inheritance. struct BaseType : Tag { - TypeIndex type; // The actual base type, without specifiers - Access access; // Access specifier. - BaseClassTraits traits; // Additional base class semantics. + TypeIndex type {}; // The actual base type, without specifiers + Access access {}; // Access specifier. + BaseClassTraits traits; // Additional base class semantics. }; // Type-id in parse tree form @@ -2031,19 +1978,10 @@ namespace ifc { } // namespace syntax // Location description of a source file + line pair - struct FileAndLine : std::pair { - FileAndLine() : std::pair() {} - FileAndLine(NameIndex index, LineNumber line) : std::pair(index, line) {} - - NameIndex file() const - { - return first; - } - - LineNumber line() const - { - return second; - } + struct FileAndLine { + NameIndex file{}; + LineNumber line{}; + bool operator==(const FileAndLine&) const = default; }; // Almost any C++ declaration can be parameterized, either directly (as a template), @@ -2057,8 +1995,8 @@ namespace ifc { // Symbolic representation of a specialization request, whether implicit or explicit. struct SpecializationForm { - DeclIndex template_decl; - ExprIndex arguments; + DeclIndex template_decl{}; + ExprIndex arguments{}; }; // This structure is used to represent a body of a constexpr function. @@ -2074,20 +2012,20 @@ namespace ifc { template struct Identity { - T name{}; // The name of the entity (either 'NameIndex' or 'TextOffset') - SourceLocation locus; // Source location of this entity + T name{}; // The name of the entity (either 'NameIndex' or 'TextOffset') + SourceLocation locus{}; // Source location of this entity }; // Symbolic representation of a function declaration. struct FunctionDecl : Tag { - Identity identity; // The name and location of this function - TypeIndex type; // Sort and index of this decl's type. Null means no type. - DeclIndex home_scope; // Enclosing scope of this declaration. - ChartIndex chart; // Function parameter list. - FunctionTraits traits; // Function traits - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this function. - ReachableProperties properties; // Set of reachable properties of this declaration + Identity identity{}; // The name and location of this function + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ChartIndex chart{}; // Function parameter list. + FunctionTraits traits{}; // Function traits + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this function. + ReachableProperties properties{}; // Set of reachable properties of this declaration }; static_assert(offsetof(FunctionDecl, identity) == 0, @@ -2108,11 +2046,11 @@ namespace ifc { // An enumerator declaration. struct EnumeratorDecl : Tag { - Identity identity; // // The name and location of this enumerator - TypeIndex type; // Sort and index of this decl's type. Null means no type. - ExprIndex initializer; // Sort and index of this declaration's initializer, if any. Null means absent. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this enumerator. + Identity identity{}; // The name and location of this enumerator + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + ExprIndex initializer{}; // Sort and index of this declaration's initializer, if any. Null means absent. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this enumerator. }; // A strongly-typed abstraction of ExprIndex which always points to ExprSort::NamedDecl. @@ -2140,9 +2078,9 @@ namespace ifc { } struct ParameterDecl : Tag { - Identity identity; // The name and location of this function parameter - TypeIndex type; // Sort and index of this decl's type. Null means no type. - ExprIndex type_constraint; // Optional type-constraint on the parameter type. + Identity identity{}; // The name and location of this function parameter + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + ExprIndex type_constraint{}; // Optional type-constraint on the parameter type. DefaultIndex initializer{}; // Default argument. Null means none was provided. uint32_t level{}; // The nesting depth of this parameter (template or function). uint32_t position{}; // The 1-based position of this parameter. @@ -2152,15 +2090,15 @@ namespace ifc { // A variable declaration, including static data members. struct VariableDecl : Tag { - Identity identity; // The name and location of this variable - TypeIndex type; // Sort and index of this decl's type. Null means no type. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex initializer; // Sort and index of this declaration's initializer, if any. Null means absent. - ExprIndex alignment; // If non-zero, explicit alignment specification, e.g. alignas(N). - ObjectTraits obj_spec; // Object traits associated with this variable. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this variable. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + Identity identity{}; // The name and location of this variable + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ExprIndex initializer{}; // Sort and index of this declaration's initializer, if any. Null means absent. + ExprIndex alignment{}; // If non-zero, explicit alignment specification, e.g. alignas(N). + ObjectTraits obj_spec{}; // Object traits associated with this variable. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this variable. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; static_assert(offsetof(VariableDecl, identity) == 0, @@ -2168,55 +2106,55 @@ namespace ifc { // A non-static data member declaration that is not a bitfield. struct FieldDecl : Tag { - Identity identity; // The name and location of this non-static data member - TypeIndex type; // Sort and index of this decl's type. Null means no type. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex initializer; // The field initializer (if any) - ExprIndex alignment; // If non-zero, explicit alignment specification, e.g. alignas(N). - ObjectTraits obj_spec; // Object traits associated with this field. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this data member. - ReachableProperties properties; // Set of reachable semantic properties of this declaration + Identity identity{}; // The name and location of this non-static data member + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ExprIndex initializer{}; // The field initializer (if any) + ExprIndex alignment{}; // If non-zero, explicit alignment specification, e.g. alignas(N). + ObjectTraits obj_spec{}; // Object traits associated with this field. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this data member. + ReachableProperties properties{}; // Set of reachable semantic properties of this declaration }; // A bitfield declaration. struct BitfieldDecl : Tag { - Identity identity; // The name and location of this bitfield - TypeIndex type; // Sort and index of this decl's type. Null means no type. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex width; // Number of bits requested for this bitfield. - ExprIndex initializer; // Sort and index of this declaration's initializer, if any. Null means absent. - ObjectTraits obj_spec; // Object traits associated with this field. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this bitfield. - ReachableProperties properties; // Set of reachable semantic properties of this declaration + Identity identity{}; // The name and location of this bitfield + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ExprIndex width{}; // Number of bits requested for this bitfield. + ExprIndex initializer{}; // Sort and index of this declaration's initializer, if any. Null means absent. + ObjectTraits obj_spec{}; // Object traits associated with this field. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this bitfield. + ReachableProperties properties{}; // Set of reachable semantic properties of this declaration }; // A declaration for a named scope, e.g. class, namespaces. struct ScopeDecl : Tag { - Identity identity; // The name and location of this scope (class or namespace) - TypeIndex type; // Sort index of this decl's type. - TypeIndex base; // Base type(s) in class inheritance. - ScopeIndex initializer; // Type definition (i.e. initializer) of this type declaration. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex alignment; // If non-zero, explicit alignment specification, e.g. alignas(N). - PackSize pack_size; // The pack size value applied to all members of this class (#pragma pack(n)) - BasicSpecifiers basic_spec; // Basic declaration specifiers. - ScopeTraits scope_spec; // Property of this scope type declaration. - Access access; // Access right to the name of this user-defined type. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + Identity identity{}; // The name and location of this scope (class or namespace) + TypeIndex type{}; // Sort index of this decl's type. + TypeIndex base{}; // Base type(s) in class inheritance. + ScopeIndex initializer{}; // Type definition (i.e. initializer) of this type declaration. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ExprIndex alignment{}; // If non-zero, explicit alignment specification, e.g. alignas(N). + PackSize pack_size{}; // The pack size value applied to all members of this class (#pragma pack(n)) + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + ScopeTraits scope_spec{}; // Property of this scope type declaration. + Access access{}; // Access right to the name of this user-defined type. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; struct EnumerationDecl : Tag { - Identity identity; // The name and location of this enumeration - TypeIndex type; // Sort index of this decl's type. - TypeIndex base; // Enumeration base type. - Sequence initializer; // Type definition (i.e. initializer) of this type declaration. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex alignment; // If non-zero, explicit alignment specification, e.g. alignas(N). - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this enumeration. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + Identity identity{}; // The name and location of this enumeration + TypeIndex type{}; // Sort index of this decl's type. + TypeIndex base{}; // Enumeration base type. + Sequence initializer{}; // Type definition (i.e. initializer) of this type declaration. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ExprIndex alignment{}; // If non-zero, explicit alignment specification, e.g. alignas(N). + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this enumeration. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; static_assert(offsetof(EnumerationDecl, identity) == 0, @@ -2226,15 +2164,17 @@ namespace ifc { // E.g. // using T = int; // namespace N = VeryLongCompanyName::NiftyDivision::AwesomeDepartment; + // template + // using Ptr = T*; // are all (type) alias declarations in the IFC. struct AliasDecl : Tag { - Identity identity; // The name and location of this alias - TypeIndex type; // The type of this alias (TypeBasis::Typename for conventional C++ type, - // TypeBasis::Namespace for a namespace, etc.) - DeclIndex home_scope; // Enclosing scope of this declaration. - TypeIndex aliasee; // The type this declaration is introducing a name for. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to the name of this type alias. + Identity identity{};// The name and location of this alias + TypeIndex type{}; // The type of this alias (TypeBasis::Typename for conventional C++ type, + // TypeBasis::Namespace for a namespace, TypeSort::Forall for alias template etc.) + DeclIndex home_scope{}; // Enclosing scope of this declaration. + TypeIndex aliasee{}; // The type this declaration is introducing a name for. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to the name of this type alias. }; static_assert(offsetof(AliasDecl, identity) == 0, @@ -2242,16 +2182,16 @@ namespace ifc { // A temploid declaration struct TemploidDecl : Tag, ParameterizedEntity { - ChartIndex chart; // The enclosing set template parameters of this entity. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + ChartIndex chart{}; // The enclosing set template parameters of this entity. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; // The core of a template. struct Template { - Identity identity; // What identifies this template - DeclIndex home_scope; // Enclosing scope of this declaration. - ChartIndex chart; // Template parameter list. - ParameterizedEntity entity; // The core parameterized entity. + Identity identity{}; // What identifies this template + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ChartIndex chart{}; // Template parameter list. + ParameterizedEntity entity{}; // The core parameterized entity. }; static_assert(offsetof(Template, identity) == 0, @@ -2259,19 +2199,19 @@ namespace ifc { // A template declaration. struct TemplateDecl : Tag, Template { - TypeIndex type; // The type of the parameterized entity. FIXME: In some sense this is redundant with - // `entity' but VC's internal representation is currently too irregular. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to the name of this template declaration. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + TypeIndex type{}; // The type of the parameterized entity. FIXME: In some sense this is redundant with + // `entity' but VC's internal representation is currently too irregular. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to the name of this template declaration. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; // A specialization of a template. struct PartialSpecializationDecl : Tag, Template { - SpecFormIndex specialization_form; // The specialization pattern: primary template + argument list. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to the name of this template specialization. - ReachableProperties properties; // The set of semantic properties reaching to outside importers. + SpecFormIndex specialization_form{}; // The specialization pattern: primary template + argument list. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to the name of this template specialization. + ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; enum class SpecializationSort : uint8_t { @@ -2281,36 +2221,36 @@ namespace ifc { }; struct SpecializationDecl : Tag { - SpecFormIndex specialization_form; // The specialization pattern: primary template + argument list. - DeclIndex decl; // The entity declared by this specialization. - SpecializationSort sort; // The specialization category. - BasicSpecifiers basic_spec; - Access access; - ReachableProperties properties; + SpecFormIndex specialization_form{}; // The specialization pattern: primary template + argument list. + DeclIndex decl{}; // The entity declared by this specialization. + SpecializationSort sort{}; // The specialization category. + BasicSpecifiers basic_spec{}; + Access access{}; + ReachableProperties properties{}; }; struct DefaultArgumentDecl : Tag { - SourceLocation locus; // The location of this default argument decl. - TypeIndex type; // The type of the default argument decl. - DeclIndex home_scope; // Enclosing scope of this declaration. - ExprIndex initializer; // The expression used to initialize the accompanying parameter when this default - // argument is used in a call expression. - BasicSpecifiers basic_spec; - Access access; - ReachableProperties properties; + SourceLocation locus{}; // The location of this default argument decl. + TypeIndex type{}; // The type of the default argument decl. + DeclIndex home_scope {}; // Enclosing scope of this declaration. + ExprIndex initializer{}; // The expression used to initialize the accompanying parameter when this default + // argument is used in a call expression. + BasicSpecifiers basic_spec{}; + Access access{}; + ReachableProperties properties{}; }; // A concept. struct ConceptDecl : Tag { - Identity identity; // What identifies this concept. - DeclIndex home_scope; // Enclosing scope of this declaration. - TypeIndex type; // The type of the parameterized entity. - ChartIndex chart; // Template parameter list. - ExprIndex constraint; // The associated constraint-expression. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to the name of this template declaration. - SentenceIndex head; // The sequence of words making up the declarative part of current instantiation. - SentenceIndex body; // The sequence of words making up the body of this concept. + Identity identity{}; // What identifies this concept. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + TypeIndex type{}; // The type of the parameterized entity. + ChartIndex chart{}; // Template parameter list. + ExprIndex constraint{}; // The associated constraint-expression. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to the name of this template declaration. + SentenceIndex head{}; // The sequence of words making up the declarative part of current instantiation. + SentenceIndex body{}; // The sequence of words making up the body of this concept. }; static_assert(offsetof(Template, identity) == 0, @@ -2318,99 +2258,99 @@ namespace ifc { // A non-static member function declaration. struct NonStaticMemberFunctionDecl : Tag { - Identity identity; // What identifies this non-static member function - TypeIndex type; // Sort and index of this decl's type. Null means no type. - DeclIndex home_scope; // Enclosing scope of this declaration. - ChartIndex chart; // Function parameter list. - FunctionTraits traits; // Function traits ('const' etc.) - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this member. - ReachableProperties properties; // Set of reachable semantic properties of this declaration + Identity identity{}; // What identifies this non-static member function + TypeIndex type{}; // Sort and index of this decl's type. Null means no type. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ChartIndex chart{}; // Function parameter list. + FunctionTraits traits{}; // Function traits ('const' etc.) + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this member. + ReachableProperties properties{}; // Set of reachable semantic properties of this declaration }; // A constructor declaration. struct ConstructorDecl : Tag { - Identity identity; // What identifies this constructor - TypeIndex type; // Type of this constructor declaration. - DeclIndex home_scope; // Enclosing scope of this declaration. - ChartIndex chart; // Function parameter list. - FunctionTraits traits; // Function traits - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this constructor. - ReachableProperties properties; // Set of reachable semantic properties of this declaration + Identity identity{}; // What identifies this constructor + TypeIndex type{}; // Type of this constructor declaration. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ChartIndex chart{}; // Function parameter list. + FunctionTraits traits{}; // Function traits + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this constructor. + ReachableProperties properties{}; // Set of reachable semantic properties of this declaration }; // A constructor declaration. struct InheritedConstructorDecl : Tag { - Identity identity; // What identifies this constructor - TypeIndex type; // Type of this contructor declaration. - DeclIndex home_scope; // Enclosing scope of this declaration. - ChartIndex chart; // Function parameter list. - FunctionTraits traits; // Function traits - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this constructor. - DeclIndex base_ctor; // The base class ctor this ctor references. + Identity identity{}; // What identifies this constructor + TypeIndex type{}; // Type of this contructor declaration. + DeclIndex home_scope{}; // Enclosing scope of this declaration. + ChartIndex chart{}; // Function parameter list. + FunctionTraits traits{}; // Function traits + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this constructor. + DeclIndex base_ctor{}; // The base class ctor this ctor references. }; // A destructor declaration. struct DestructorDecl : Tag { - Identity identity; // What identifies this destructor - DeclIndex home_scope; // Enclosing scope of this declaration. - NoexceptSpecification eh_spec; // Exception specification. - FunctionTraits traits; // Function traits. - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // Access right to this destructor. - CallingConvention convention; // Calling convention. - ReachableProperties properties; // Set of reachable semantic properties of this declaration + Identity identity{}; // What identifies this destructor + DeclIndex home_scope{}; // Enclosing scope of this declaration. + NoexceptSpecification eh_spec{}; // Exception specification. + FunctionTraits traits{}; // Function traits. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // Access right to this destructor. + CallingConvention convention{}; // Calling convention. + ReachableProperties properties{}; // Set of reachable semantic properties of this declaration }; // A deduction guide for class template. // Note: If the deduction guide was paramterized by a template, then this would be // the corresponding parameterized decl. The template declaration itself has no name. struct DeductionGuideDecl : Tag { - Identity identity; // associated primary template and location of declaration - DeclIndex home_scope; // Enclosing scope of this declaration - ChartIndex source; // Function parameters mentioned in the deduction guide declaration - ExprIndex target; // Pattern for the template-argument list to deduce - GuideTraits traits; // Deduction guide traits. - BasicSpecifiers basic_spec; // Basic declaration specifiers. + Identity identity{}; // associated primary template and location of declaration + DeclIndex home_scope{}; // Enclosing scope of this declaration + ChartIndex source{}; // Function parameters mentioned in the deduction guide declaration + ExprIndex target{}; // Pattern for the template-argument list to deduce + GuideTraits traits{}; // Deduction guide traits. + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. }; // Declaration introducing no names, e.g. static_assert, asm-declaration, empty-declaration struct BarrenDecl : Tag { - DirIndex directive; - BasicSpecifiers basic_spec; - Access access; + DirIndex directive{}; + BasicSpecifiers basic_spec{}; + Access access{}; }; struct ReferenceDecl : Tag { - ModuleReference translation_unit; // The owning TU of this decl. - DeclIndex local_index; // The core declaration. + ModuleReference translation_unit{}; // The owning TU of this decl. + DeclIndex local_index{}; // The core declaration. }; // A property declaration -- VC extensions. struct PropertyDecl : Tag { - DeclIndex data_member; // The pseudo data member that represents this property - TextOffset get_method_name; // The name of the 'get' method - TextOffset set_method_name; // The name of the 'set' method + DeclIndex data_member{}; // The pseudo data member that represents this property + TextOffset get_method_name{}; // The name of the 'get' method + TextOffset set_method_name{}; // The name of the 'set' method }; struct SegmentDecl : Tag { - TextOffset name; // offset of name's text in the string table. - TextOffset class_id; // Class ID of the segment. - SegmentTraits seg_spec; // Attributes collected from #pragmas, for linker use. - SegmentType type; // The type of segment. + TextOffset name{}; // offset of name's text in the string table. + TextOffset class_id{}; // Class ID of the segment. + SegmentTraits seg_spec{}; // Attributes collected from #pragmas, for linker use. + SegmentType type{}; // The type of segment. }; struct UsingDecl : Tag { - Identity identity; // What identifies this using declaration - DeclIndex home_scope; // Enclosing scope of this declaration. - DeclIndex resolution; // Designates the used set of declarations. - ExprIndex parent; // If this is a member using declaration then this is the introducing base-class - TextOffset name; // If this is a member using declaration then this is the name of member - BasicSpecifiers basic_spec; // Basic declaration specifiers. - Access access; // If this is a member using declaration then this is its access - bool is_hidden; // Is this using-declaration hidden? + Identity identity{}; // What identifies this using declaration + DeclIndex home_scope{}; // Enclosing scope of this declaration. + DeclIndex resolution{}; // Designates the used set of declarations. + ExprIndex parent{}; // If this is a member using declaration then this is the introducing base-class + TextOffset name{}; // If this is a member using declaration then this is the name of member + BasicSpecifiers basic_spec{}; // Basic declaration specifiers. + Access access{}; // If this is a member using declaration then this is its access + bool is_hidden{}; // Is this using-declaration hidden? }; struct FriendDecl : Tag { @@ -2421,8 +2361,8 @@ namespace ifc { }; struct ExpansionDecl : Tag { - SourceLocation locus; // Location of the expansion - DeclIndex operand; // The declaration to expand + SourceLocation locus{}; // Location of the expansion + DeclIndex operand{}; // The declaration to expand }; struct SyntacticDecl : Tag { @@ -2540,7 +2480,7 @@ namespace ifc { }; struct ExpansionStmt : Location { - StmtIndex operand; // The statement to expand + StmtIndex operand{}; // The statement to expand }; struct TupleStmt : LocationAndType, Sequence {}; @@ -2551,9 +2491,9 @@ namespace ifc { inline constexpr auto immediate_upper_bound = uint64_t(1) << index_like::index_precision; struct StringLiteral { - TextOffset start; // beginning of the first byte in this string literal - Cardinality size; // The number of bytes in the object representation, including terminator(s). - TextOffset suffix; // Suffix, if any. + TextOffset start{}; // beginning of the first byte in this string literal + Cardinality size{}; // The number of bytes in the object representation, including terminator(s). + TextOffset suffix{}; // Suffix, if any. }; struct TypeExpr : LocationAndType { @@ -2860,10 +2800,6 @@ namespace ifc { SyntaxIndex syntax{}; // The representation of this expression as a parse tree }; - struct SubobjectValueExpr : Tag { - ExprIndex value{}; // The value of this member object - }; - struct ProductTypeValueExpr : LocationAndType { TypeIndex structure{}; // The class type which this value is associated ExprIndex members{}; // The members (zero or more) which are initialized @@ -2875,13 +2811,12 @@ namespace ifc { struct SumTypeValueExpr : LocationAndType { TypeIndex variant{}; // The union type which this value is associated ActiveMemberIndex active_member{}; // The active member index - SubobjectValueExpr value{}; // The object representing the value of the active member + ExprIndex value{}; // The object representing the value of the active member }; struct ArrayValueExpr : LocationAndType { ExprIndex elements{}; // The tuple containing the element expressions TypeIndex element_type{}; // The type of elements within the array - // TypeIndex array_type { }; // The type of the array object }; struct ObjectLikeMacro : Tag { @@ -2918,8 +2853,8 @@ namespace ifc { #pragma pack(4) struct LiteralReal { - double value; - uint16_t size; + double value{}; + uint16_t size{}; }; #pragma pack() @@ -3081,8 +3016,8 @@ namespace ifc { }; struct KeywordForm : Tag { - SourceLocation locus; - TextOffset spelling; + SourceLocation locus{}; + TextOffset spelling{}; }; struct WhitespaceForm : Tag { diff --git a/include/ifc/operators.hxx b/include/ifc/operators.hxx index e686421..208e41e 100644 --- a/include/ifc/operators.hxx +++ b/include/ifc/operators.hxx @@ -83,6 +83,7 @@ namespace ifc { PseudoDtorCall, // p->~T(), with T a scalar type LookupGlobally, // ::x Artificial, // Compiler-generated expression wrapper + MetaDescriptor, // a runtime reification of a type Msvc = 0x0400, MsvcAssume, // __assume(x) @@ -137,6 +138,7 @@ namespace ifc { // This operator attempts to catch these offending dependent expression values. MsvcConfusedSubstitution, // Represents a template parameter substitution 'P -> expr' where 'expr' could be a type or a non-type argument replacement. MsvcConfusedAggregateReturn, // Decorates a return statement which returns an aggregate class type with a user-defined destructor. + MsvcConfusedVftblPointerInit, // An initialization of a derived class's vftbl pointer. Last }; diff --git a/include/ifc/reader.hxx b/include/ifc/reader.hxx index eeb36d5..1dddedd 100644 --- a/include/ifc/reader.hxx +++ b/include/ifc/reader.hxx @@ -345,7 +345,6 @@ namespace ifc { case ExprSort::HierarchyConversion: return std::forward(f)(get(index)); case ExprSort::ProductTypeValue: return std::forward(f)(get(index)); case ExprSort::SumTypeValue: return std::forward(f)(get(index)); - case ExprSort::SubobjectValue: return std::forward(f)(get(index)); case ExprSort::ArrayValue: return std::forward(f)(get(index)); case ExprSort::DynamicDispatch: return std::forward(f)(get(index)); case ExprSort::VirtualFunctionConversion: return std::forward(f)(get(index)); diff --git a/src/ifc-dom/exprs.cxx b/src/ifc-dom/exprs.cxx index 1179ad2..460fceb 100644 --- a/src/ifc-dom/exprs.cxx +++ b/src/ifc-dom/exprs.cxx @@ -255,11 +255,6 @@ namespace ifc::util { { node.props.emplace("ref", ctx.ref(expr.variant)); node.props.emplace("index", std::to_string((int)expr.active_member)); - add_child(expr.value.value); // reach inside. no need to have it doubly nested - } - - void operator()(const symbolic::SubobjectValueExpr& expr) - { add_child(expr.value); } diff --git a/src/ifc-dom/types.cxx b/src/ifc-dom/types.cxx index 1a1b244..6c87be8 100644 --- a/src/ifc-dom/types.cxx +++ b/src/ifc-dom/types.cxx @@ -33,12 +33,12 @@ namespace ifc::util { std::string operator()(const symbolic::ExpansionType& type) { - return ctx.ref(type.operand) + to_string(type.mode); + return ctx.ref(type.pack) + to_string(type.mode); } std::string operator()(const symbolic::PointerType& ptr) { - return ctx.ref(ptr.operand) + "*"; + return ctx.ref(ptr.pointee) + "*"; } std::string operator()(const symbolic::PointerToMemberType& ptr) @@ -48,11 +48,11 @@ namespace ifc::util { std::string operator()(const symbolic::LvalueReferenceType& type) { - return ctx.ref(type.operand) + "&"; + return ctx.ref(type.referee) + "&"; } std::string operator()(const symbolic::RvalueReferenceType& type) { - return ctx.ref(type.operand) + "&&"; + return ctx.ref(type.referee) + "&&"; } std::string operator()(const symbolic::FunctionType& type) { @@ -186,12 +186,12 @@ namespace ifc::util { void operator()(const symbolic::ExpansionType& type) { node.props.emplace("mode", to_string(type.mode)); - add_child(type.operand); + add_child(type.pack); } void operator()(const symbolic::PointerType& ptr) { - add_child(ptr.operand); + add_child(ptr.pointee); } void operator()(const symbolic::PointerToMemberType& ptr) @@ -202,12 +202,12 @@ namespace ifc::util { void operator()(const symbolic::LvalueReferenceType& type) { - add_child(type.operand); + add_child(type.referee); } void operator()(const symbolic::RvalueReferenceType& type) { - add_child(type.operand); + add_child(type.referee); } void operator()(const symbolic::FunctionType& type) diff --git a/src/ifc-reader/util.cxx b/src/ifc-reader/util.cxx index defae72..2eb70d0 100644 --- a/src/ifc-reader/util.cxx +++ b/src/ifc-reader/util.cxx @@ -389,7 +389,7 @@ namespace ifc::util { std::string to_string(symbolic::TypeBasis basis) { - return to_string(symbolic::FundamentalType{basis, {}, {}}); + return to_string(symbolic::FundamentalType{.basis = basis}); } } // namespace ifc::util diff --git a/src/sgraph.cxx b/src/sgraph.cxx index 211acc3..6739f6b 100644 --- a/src/sgraph.cxx +++ b/src/sgraph.cxx @@ -169,7 +169,7 @@ namespace ifc { {ExprSort::HierarchyConversion, "expr.hierarchy-conversion"}, {ExprSort::ProductTypeValue, "expr.product-type-value"}, {ExprSort::SumTypeValue, "expr.sum-type-value"}, - {ExprSort::SubobjectValue, "expr.class-subobject-value"}, + {ExprSort::UnusedSort1, "expr.unused1"}, {ExprSort::ArrayValue, "expr.array-value"}, {ExprSort::DynamicDispatch, "expr.dynamic-dispatch"}, {ExprSort::VirtualFunctionConversion, "expr.virtual-function-conversion"},