{
using Visitor::visit;
- tree type_;
+ tree decl_;
vec<constructor_elt, va_gc> *init_;
+ /* Build an internal comdat symbol for the manifest constant VALUE, so that
+ its address can be taken. */
+
+ tree internal_reference (tree value)
+ {
+ /* Use the typeinfo decl name as a prefix for the internal symbol. */
+ const char *prefix = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (this->decl_));
+ tree decl = build_artificial_decl (TREE_TYPE (value), value, prefix);
+
+ /* The internal pointer reference should be public, but not visible outside
+ the compilation unit. */
+ DECL_EXTERNAL (decl) = 0;
+ TREE_PUBLIC (decl) = 1;
+ DECL_VISIBILITY (decl) = VISIBILITY_INTERNAL;
+ DECL_COMDAT (decl) = 1;
+ d_pushdecl (decl);
+
+ return decl;
+ }
+
/* Add VALUE to the constructor values list. */
void layout_field (tree value)
TREE_STATIC (value) = 1;
/* Taking the address, so assign the literal to a static var. */
- tree decl = build_artificial_decl (TREE_TYPE (value), value);
+ tree decl = this->internal_reference (value);
TREE_READONLY (decl) = 1;
- DECL_EXTERNAL (decl) = 0;
- d_pushdecl (decl);
value = d_array_value (build_ctype (Type::tchar->arrayOf ()),
size_int (len), build_address (decl));
public:
- TypeInfoVisitor (tree type)
+ TypeInfoVisitor (tree decl)
{
- this->type_ = type;
+ this->decl_ = decl;
this->init_ = NULL;
}
tree result (void)
{
- return build_struct_literal (this->type_, this->init_);
+ return build_struct_literal (TREE_TYPE (this->decl_), this->init_);
}
/* Layout of TypeInfo is:
build_typeinfo (d->loc, arg->type));
}
tree ctor = build_constructor (build_ctype (satype), elms);
- tree decl = build_artificial_decl (TREE_TYPE (ctor), ctor);
-
- /* The internal pointer reference should be public, but not visible outside
- the compilation unit, as it's referencing COMDAT decls. */
- TREE_PUBLIC (decl) = 1;
- DECL_VISIBILITY (decl) = VISIBILITY_INTERNAL;
- DECL_COMDAT (decl) = 1;
+ tree decl = this->internal_reference (ctor);
tree length = size_int (ti->arguments->dim);
tree ptr = build_address (decl);
this->layout_field (d_array_value (array_type_node, length, ptr));
- d_pushdecl (decl);
rest_of_decl_compilation (decl, 1, 0);
}
};
if (!Type::dtypeinfo)
create_frontend_tinfo_types ();
- tree type = TREE_TYPE (get_typeinfo_decl (d));
- TypeInfoVisitor v = TypeInfoVisitor (type);
+ TypeInfoVisitor v = TypeInfoVisitor (get_typeinfo_decl (d));
d->accept (&v);
return v.result ();
}
create_frontend_tinfo_types ();
TypeInfoClassDeclaration *d = TypeInfoClassDeclaration::create (cd->type);
- tree type = TREE_TYPE (get_classinfo_decl (cd));
- TypeInfoVisitor v = TypeInfoVisitor (type);
+ TypeInfoVisitor v = TypeInfoVisitor (get_classinfo_decl (cd));
d->accept (&v);
return v.result ();
}