gccint: Classes

1 
1 11.10.3 Classes
1 ---------------
1 
1 Besides namespaces, the other high-level scoping construct in C++ is the
1 class.  (Throughout this manual the term "class" is used to mean the
1 types referred to in the ANSI/ISO C++ Standard as classes; these include
1 types defined with the 'class', 'struct', and 'union' keywords.)
1 
1  A class type is represented by either a 'RECORD_TYPE' or a
1 'UNION_TYPE'.  A class declared with the 'union' tag is represented by a
1 'UNION_TYPE', while classes declared with either the 'struct' or the
1 'class' tag are represented by 'RECORD_TYPE's.  You can use the
1 'CLASSTYPE_DECLARED_CLASS' macro to discern whether or not a particular
1 type is a 'class' as opposed to a 'struct'.  This macro will be true
1 only for classes declared with the 'class' tag.
1 
1  Almost all members are available on the 'TYPE_FIELDS' list.  Given one
1 member, the next can be found by following the 'TREE_CHAIN'.  You should
1 not depend in any way on the order in which fields appear on this list.
1 All nodes on this list will be 'DECL' nodes.  A 'FIELD_DECL' is used to
1 represent a non-static data member, a 'VAR_DECL' is used to represent a
1 static data member, and a 'TYPE_DECL' is used to represent a type.  Note
1 that the 'CONST_DECL' for an enumeration constant will appear on this
1 list, if the enumeration type was declared in the class.  (Of course,
1 the 'TYPE_DECL' for the enumeration type will appear here as well.)
1 There are no entries for base classes on this list.  In particular,
1 there is no 'FIELD_DECL' for the "base-class portion" of an object.  If
1 a function member is overloaded, each of the overloaded functions
1 appears; no 'OVERLOAD' nodes appear on the 'TYPE_FIELDS' list.
1 Implicitly declared functions (including default constructors, copy
1 constructors, assignment operators, and destructors) will appear on this
1 list as well.
1 
1  The 'TYPE_VFIELD' is a compiler-generated field used to point to
1 virtual function tables.  It may or may not appear on the 'TYPE_FIELDS'
1 list.  However, back ends should handle the 'TYPE_VFIELD' just like all
1 the entries on the 'TYPE_FIELDS' list.
1 
1  Every class has an associated "binfo", which can be obtained with
1 'TYPE_BINFO'.  Binfos are used to represent base-classes.  The binfo
1 given by 'TYPE_BINFO' is the degenerate case, whereby every class is
1 considered to be its own base-class.  The base binfos for a particular
1 binfo are held in a vector, whose length is obtained with
1 'BINFO_N_BASE_BINFOS'.  The base binfos themselves are obtained with
1 'BINFO_BASE_BINFO' and 'BINFO_BASE_ITERATE'.  To add a new binfo, use
1 'BINFO_BASE_APPEND'.  The vector of base binfos can be obtained with
1 'BINFO_BASE_BINFOS', but normally you do not need to use that.  The
1 class type associated with a binfo is given by 'BINFO_TYPE'.  It is not
1 always the case that 'BINFO_TYPE (TYPE_BINFO (x))', because of typedefs
1 and qualified types.  Neither is it the case that 'TYPE_BINFO
1 (BINFO_TYPE (y))' is the same binfo as 'y'.  The reason is that if 'y'
1 is a binfo representing a base-class 'B' of a derived class 'D', then
1 'BINFO_TYPE (y)' will be 'B', and 'TYPE_BINFO (BINFO_TYPE (y))' will be
1 'B' as its own base-class, rather than as a base-class of 'D'.
1 
1  The access to a base type can be found with 'BINFO_BASE_ACCESS'.  This
1 will produce 'access_public_node', 'access_private_node' or
1 'access_protected_node'.  If bases are always public,
1 'BINFO_BASE_ACCESSES' may be 'NULL'.
1 
1  'BINFO_VIRTUAL_P' is used to specify whether the binfo is inherited
1 virtually or not.  The other flags, 'BINFO_FLAG_0' to 'BINFO_FLAG_6',
1 can be used for language specific use.
1 
1  The following macros can be used on a tree node representing a
1 class-type.
1 
1 'LOCAL_CLASS_P'
1      This predicate holds if the class is local class _i.e._ declared
1      inside a function body.
1 
1 'TYPE_POLYMORPHIC_P'
1      This predicate holds if the class has at least one virtual function
1      (declared or inherited).
1 
1 'TYPE_HAS_DEFAULT_CONSTRUCTOR'
1      This predicate holds whenever its argument represents a class-type
1      with default constructor.
1 
1 'CLASSTYPE_HAS_MUTABLE'
1 'TYPE_HAS_MUTABLE_P'
1      These predicates hold for a class-type having a mutable data
1      member.
1 
1 'CLASSTYPE_NON_POD_P'
1      This predicate holds only for class-types that are not PODs.
1 
1 'TYPE_HAS_NEW_OPERATOR'
1      This predicate holds for a class-type that defines 'operator new'.
1 
1 'TYPE_HAS_ARRAY_NEW_OPERATOR'
1      This predicate holds for a class-type for which 'operator new[]' is
1      defined.
1 
1 'TYPE_OVERLOADS_CALL_EXPR'
1      This predicate holds for class-type for which the function call
1      'operator()' is overloaded.
1 
1 'TYPE_OVERLOADS_ARRAY_REF'
1      This predicate holds for a class-type that overloads 'operator[]'
1 
1 'TYPE_OVERLOADS_ARROW'
1      This predicate holds for a class-type for which 'operator->' is
1      overloaded.
1