Studying note of GCC-3.4.6 source (142)
2011-01-15 10:51
369 查看
5.12.5.2.2.2.1.3.12.
Finish the derived
RECORD_TYPE – generate VTT
Virtual table table (VTT) is not mandatory for class, so build_vtt
below may generate VTT or may not. Note dump_class_hierarchy
below at line 5188,
option –fdump-class-hierarchy will trigger the function to dump content we see
in previous section.
finish_struct_1 (continue)
5174
/* Build the VTT
for T.
*/
5175
build_vtt
(t);
5176
5177
if (warn_nonvdtor
&&
TYPE_POLYMORPHIC_P (t) && TYPE_HAS_DESTRUCTOR (t)
5178
&& DECL_VINDEX
(TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1)) == NULL_TREE)
5179
warning ("`%#T' has virtual functions
but non-virtual destructor", t);
5180
5181
complete_vars (t);
5182
5183
if (warn_overloaded_virtual
)
5184
warn_hidden (t);
5185
5186
maybe_suppress_debug_info (t);
5187
5188
dump_class_hierarchy (t);
5189
5190
/* Finish debugging
output for this type.
*/
5191
rest_of_type_compilation (t, ! LOCAL_CLASS_P
(t));
5192
}
While for class contains virtual base, virtual table constructed
above is not the final one. It requires virtual table table (VTT) in place of
virtual table. A VTT holds:
1. primary
virtual pointer for complete object of the most derived class.
2. secondary
VTTs for each direct non-virtual base of the most derived class which requires
a VTT.
3. secondary
virtual pointers for each direct or indirect base of the most derived class
which has virtual bases or is reachable via a virtual path from the most
derived class.
4. secondary VTTs for each direct or indirect virtual base of the
most derived class.
Secondary VTTs look like complete object VTTs without part 4.
About VTT and layout with inheritage, here
is a good note, we abstract it here.
Finish the derived
RECORD_TYPE – generate VTT
Virtual table table (VTT) is not mandatory for class, so build_vtt
below may generate VTT or may not. Note dump_class_hierarchy
below at line 5188,
option –fdump-class-hierarchy will trigger the function to dump content we see
in previous section.
finish_struct_1 (continue)
5174
/* Build the VTT
for T.
*/
5175
build_vtt
(t);
5176
5177
if (warn_nonvdtor
&&
TYPE_POLYMORPHIC_P (t) && TYPE_HAS_DESTRUCTOR (t)
5178
&& DECL_VINDEX
(TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1)) == NULL_TREE)
5179
warning ("`%#T' has virtual functions
but non-virtual destructor", t);
5180
5181
complete_vars (t);
5182
5183
if (warn_overloaded_virtual
)
5184
warn_hidden (t);
5185
5186
maybe_suppress_debug_info (t);
5187
5188
dump_class_hierarchy (t);
5189
5190
/* Finish debugging
output for this type.
*/
5191
rest_of_type_compilation (t, ! LOCAL_CLASS_P
(t));
5192
}
While for class contains virtual base, virtual table constructed
above is not the final one. It requires virtual table table (VTT) in place of
virtual table. A VTT holds:
1. primary
virtual pointer for complete object of the most derived class.
2. secondary
VTTs for each direct non-virtual base of the most derived class which requires
a VTT.
3. secondary
virtual pointers for each direct or indirect base of the most derived class
which has virtual bases or is reachable via a virtual path from the most
derived class.
4. secondary VTTs for each direct or indirect virtual base of the
most derived class.
Secondary VTTs look like complete object VTTs without part 4.
About VTT and layout with inheritage, here
is a good note, we abstract it here.
TheAs we discussed in |
相关文章推荐
- Studying note of GCC-3.4.6 source (142 - continue)
- Studying note of GCC-3.4.6 source (58)
- Studying note of GCC-3.4.6 source (63)
- Studying note of GCC-3.4.6 source (73)
- Studying note of GCC-3.4.6 source (97)
- Studying note of GCC-3.4.6 source (106)
- Studying note of GCC-3.4.6 source (112)
- Studying note of GCC-3.4.6 source (116)
- Studying note of GCC-3.4.6 source (128)
- Studying note of GCC-3.4.6 source (130)
- Studying note of GCC-3.4.6 source (138)
- Studying note of GCC-3.4.6 source (6)
- Studying note of GCC-3.4.6 source (7)
- Studying note of GCC-3.4.6 source (9)
- Studying note of GCC-3.4.6 source (141 - cont 1)
- Studying note of GCC-3.4.6 source (151)
- Studying note of GCC-3.4.6 source (158)
- Studying note of GCC-3.4.6 source (163)
- Studying note of GCC-3.4.6 source (31)
- Studying note of GCC-3.4.6 source (42)