cp-tree.h (get_tinfo_decl_direct): Declare.

gcc/cp/
	* cp-tree.h (get_tinfo_decl_direct): Declare.
	* module.cc (trees_out::tree_decl): Stream more tinfo_var info.
	(trees_in::tree_value): Use get_tinfo_decl_direct for tinfo vars.
	* rtti.c (get_tinfo_decl_direct): Break out of ...
	(get_tinfo_decl): ... here.  Call it.

From-SVN: r273137
This commit is contained in:
Nathan Sidwell
2019-07-05 13:02:30 +00:00
committed by Nathan Sidwell
parent 6f2a78e717
commit 309d354cdf
4 changed files with 69 additions and 25 deletions

View File

@@ -1,3 +1,12 @@
2019-07-05 Nathan Sidwell <nathan@acm.org>
gcc/cp/
* cp-tree.h (get_tinfo_decl_direct): Declare.
* module.cc (trees_out::tree_decl): Stream more tinfo_var info.
(trees_in::tree_value): Use get_tinfo_decl_direct for tinfo vars.
* rtti.c (get_tinfo_decl_direct): Break out of ...
(get_tinfo_decl): ... here. Call it.
2019-07-04 Nathan Sidwell <nathan@acm.org>
gcc/cp/

View File

@@ -7085,6 +7085,7 @@ extern GTY(()) vec<tree, va_gc> *unemitted_tinfo_decls;
extern void init_rtti_processing (void);
extern tree build_typeid (tree, tsubst_flags_t);
extern tree get_tinfo_decl_direct (tree, tree, int);
extern tree get_tinfo_decl (tree);
extern tree get_typeid (tree, tsubst_flags_t);
extern tree build_headof (tree);

View File

@@ -6911,15 +6911,22 @@ trees_out::tree_decl (tree decl, walk_kind ref, bool looking_inside)
{
/* A typeinfo object -> tt_tinfo_var. These need recreating by
the loader. The type it is for is stashed on the name's
TREE_TYPE. */
TREE_TYPE. But we also need the mangled name and pseudo
index, so the reader doesn't need to complete the type
(which would break section ordering). */
tree type = TREE_TYPE (DECL_NAME (decl));
unsigned ix = get_pseudo_tinfo_index (TREE_TYPE (decl));
if (streaming_p ())
i (tt_tinfo_var);
{
i (tt_tinfo_var);
u (ix);
}
tree_node (type);
tree_node (DECL_NAME (decl));
int tag = insert (decl);
if (streaming_p ())
dump (dumper::TREE)
&& dump ("Wrote typeinfo:%d %S for %N", tag, decl, type);
&& dump ("Wrote tinfo_var:%d %S:%u for %N", tag, decl, ix, type);
return false;
}
@@ -8425,22 +8432,35 @@ trees_in::tree_node ()
break;
case tt_tinfo_var:
case tt_conv_id:
/* A typeinfo var or conversion operator. Get the type and
recreate the var decl or identifier. */
{
bool is_tinfo = tag == tt_tinfo_var;
unsigned ix = u ();
tree type = tree_node ();
if (type && TYPE_P (type))
tree name = tree_node ();
if (!get_overrun ())
{
res = is_tinfo ? get_tinfo_decl (type) : make_conv_op_name (type);
res = get_tinfo_decl_direct (type, name, int (ix));
int tag = insert (res);
dump (dumper::TREE)
&& dump ("Created %s:%d %S for %N",
is_tinfo ? "tinfo_var" : "conv_op", tag, res, type);
&& dump ("Created tinfo_var:%d %S:%u for %N", tag, res, ix, type);
}
}
break;
case tt_conv_id:
/* A conversion operator. Get the type and recreate the
identifier. */
{
tree type = tree_node ();
if (!get_overrun ())
{
res = make_conv_op_name (type);
int tag = insert (res);
dump (dumper::TREE)
&& dump ("Created conv_op:%d %S for %N", tag, res, type);
}
else
set_overrun ();
}
break;

View File

@@ -417,9 +417,6 @@ tinfo_name (tree type, bool mark_private)
tree
get_tinfo_decl (tree type)
{
tree name;
tree d;
if (variably_modified_type_p (type, /*fn=*/NULL_TREE))
{
error ("cannot create type information for type %qT because "
@@ -432,25 +429,41 @@ get_tinfo_decl (tree type)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
type = complete_type (type);
return get_tinfo_decl_direct (type, NULL, -1);
}
/* Get or create a tinfo VAR_DECL directly from the provided information.
The caller must have already checked it is valid to do so. */
tree
get_tinfo_decl_direct (tree type, tree name, int pseudo_ix)
{
/* For a class type, the variable is cached in the type node
itself. */
tree d;
gcc_checking_assert (TREE_CODE (type) != METHOD_TYPE);
if (pseudo_ix < 0)
type = complete_type (type);
if (CLASS_TYPE_P (type))
{
d = CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type));
if (d)
return d;
}
d = CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type));
name = mangle_typeinfo_for_type (type);
if (!name)
name = mangle_typeinfo_for_type (type);
if (!CLASS_TYPE_P (type))
d = get_global_binding (name);
d = get_global_binding (name);
if (!d)
{
int ix = get_pseudo_ti_index (type);
const tinfo_s *ti = get_tinfo_desc (ix);
/* Create it. */
if (pseudo_ix < 0)
pseudo_ix = get_pseudo_ti_index (type);
const tinfo_s *ti = get_tinfo_desc (pseudo_ix);
d = build_lang_decl (VAR_DECL, name, ti->type);
SET_DECL_ASSEMBLER_NAME (d, name);
/* Remember the type it is for. */
@@ -460,6 +473,7 @@ get_tinfo_decl (tree type)
DECL_IGNORED_P (d) = 1;
TREE_READONLY (d) = 1;
TREE_STATIC (d) = 1;
/* Mark the variable as undefined -- but remember that we can
define it later if we need to do so. */
DECL_EXTERNAL (d) = 1;