2017-10-05 Nathan Sidwell <nathan@acm.org>
+ Kill IDENTIFIER_GLOBAL_VALUE, SET_IDENTIFIER_GLOBAL_VALUE
+ * cp-tree.h (IDENTIFIER_GLOBAL_VALUE,
+ SET_IDENTIFIER_GLOBAL_VALUE): Delete.
+ * name-lookup.h (set_global_binding): Remove NAME parm.
+ (get_global_binding): New inline fn.
+ * name-lookup.c (set_global_binding): Remove NAME parm. Adjust.
+ (identifier_global_value): Move to ...
+ * cp-objcp-common.c (identifier_global_value): ... here.
+ * class.c (build_ctor_vtbl_group, build_vtbl_initializer): Adjust.
+ * decl.c (record_builtin_type, expand_static_init,
+ grokdeclarator): Adjust.
+ * decl2.c (get_guard, get_local_tls_init_fn, get_tls_init_fn,
+ get_tls_wrapper_fn, maybe_warn_sized_delete): Adjust.
+ * except.c (declare_library_fn, build_throw): Adjust.
+ * init.c (throw_bad_array_length): Adjust.
+ * rtti.c (throw_bad_cast, throw_bad_typeid, get_tinfo_decl): Adjust.
+
* decl2.c (record_mangling): Fix spello and formatting from
previous patch.
/* See if we've already created this construction vtable group. */
id = mangle_ctor_vtbl_for_type (t, binfo);
- if (IDENTIFIER_GLOBAL_VALUE (id))
+ if (get_global_binding (id))
return;
gcc_assert (!SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t));
if (!dvirt_fn)
{
tree name = get_identifier ("__cxa_deleted_virtual");
- dvirt_fn = IDENTIFIER_GLOBAL_VALUE (name);
+ dvirt_fn = get_global_binding (name);
if (!dvirt_fn)
dvirt_fn = push_library_fn
(name,
return pushdecl (decl);
}
+/* Get the global value binding of NAME. Called directly from
+ c-common.c, not via a hook. */
+
+tree
+identifier_global_value (tree name)
+{
+ return get_global_binding (name);
+}
+
/* Register c++-specific dumps. */
void
};
typedef struct ptrmem_cst * ptrmem_cst_t;
-#define IDENTIFIER_GLOBAL_VALUE(NODE) \
- get_namespace_binding (NULL_TREE, (NODE))
-#define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \
- set_global_binding ((NODE), (VAL))
-
#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
#define BIND_EXPR_TRY_BLOCK(NODE) \
RID_POINTERS. NAME is the name used when looking up the builtin
type. TYPE is the _TYPE node for the builtin type.
- The calls to SET_IDENTIFIER_GLOBAL_VALUE below should be
+ The calls to set_global_binding below should be
eliminated. Built-in types should not be looked up name; their
names are keywords that the parser can recognize. However, there
is code in c-common.c that uses identifier_global_value to look up
tree tname = get_identifier (name);
tree tdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, tname, type);
DECL_ARTIFICIAL (tdecl) = 1;
- SET_IDENTIFIER_GLOBAL_VALUE (tname, tdecl);
+ set_global_binding (tdecl);
decl = tdecl;
}
{
tree rdecl = build_decl (BUILTINS_LOCATION, TYPE_DECL, rname, type);
DECL_ARTIFICIAL (rdecl) = 1;
- SET_IDENTIFIER_GLOBAL_VALUE (rname, rdecl);
+ set_global_binding (rdecl);
if (!decl)
decl = rdecl;
}
}
/* Like build_library_fn, but also pushes the function so that we will
- be able to find it via IDENTIFIER_GLOBAL_VALUE. Also, the function
+ be able to find it via get_global_binding. Also, the function
may throw exceptions listed in RAISES. */
tree
acquire_name = get_identifier ("__cxa_guard_acquire");
release_name = get_identifier ("__cxa_guard_release");
abort_name = get_identifier ("__cxa_guard_abort");
- acquire_fn = identifier_global_value (acquire_name);
- release_fn = identifier_global_value (release_name);
- abort_fn = identifier_global_value (abort_name);
+ acquire_fn = get_global_binding (acquire_name);
+ release_fn = get_global_binding (release_name);
+ abort_fn = get_global_binding (abort_name);
if (!acquire_fn)
acquire_fn = push_library_fn
(acquire_name, build_function_type_list (integer_type_node,
gcc_assert (flags == NO_SPECIAL);
flags = TYPENAME_FLAG;
sfk = sfk_conversion;
- tree glob = IDENTIFIER_GLOBAL_VALUE (dname);
+ tree glob = get_global_binding (dname);
if (glob && TREE_CODE (glob) == TYPE_DECL)
name = identifier_to_locale (IDENTIFIER_POINTER (dname));
else
tree guard;
sname = mangle_guard_variable (decl);
- guard = IDENTIFIER_GLOBAL_VALUE (sname);
+ guard = get_global_binding (sname);
if (! guard)
{
tree guard_type;
get_local_tls_init_fn (void)
{
tree sname = get_identifier ("__tls_init");
- tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+ tree fn = get_global_binding (sname);
if (!fn)
{
fn = build_lang_decl (FUNCTION_DECL, sname,
TREE_PUBLIC (fn) = false;
DECL_ARTIFICIAL (fn) = true;
mark_used (fn);
- SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+ set_global_binding (fn);
}
return fn;
}
return get_local_tls_init_fn ();
tree sname = mangle_tls_init_fn (var);
- tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+ tree fn = get_global_binding (sname);
if (!fn)
{
fn = build_lang_decl (FUNCTION_DECL, sname,
DECL_BEFRIENDING_CLASSES (fn) = var;
- SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+ set_global_binding (fn);
}
return fn;
}
return NULL_TREE;
tree sname = mangle_tls_wrapper_fn (var);
- tree fn = IDENTIFIER_GLOBAL_VALUE (sname);
+ tree fn = get_global_binding (sname);
if (!fn)
{
/* A named rvalue reference is an lvalue, so the wrapper should
DECL_BEFRIENDING_CLASSES (fn) = var;
- SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
+ set_global_binding (fn);
}
return fn;
}
tree sized = NULL_TREE;
tree unsized = NULL_TREE;
- for (ovl_iterator iter (IDENTIFIER_GLOBAL_VALUE (cp_operator_id (code)));
+ for (ovl_iterator iter (get_global_binding (cp_operator_id (code)));
iter; ++iter)
{
tree fn = *iter;
int ecf, int tm_ecf)
{
tree ident = get_identifier (name);
- tree res = IDENTIFIER_GLOBAL_VALUE (ident);
+ tree res = get_global_binding (ident);
if (!res)
{
tree type = build_function_type_list (rtype, ptype, NULL_TREE);
char *tm_name = concat ("_ITM_", name + 2, NULL_TREE);
tree tm_ident = get_identifier (tm_name);
free (tm_name);
- tree tm_fn = IDENTIFIER_GLOBAL_VALUE (tm_ident);
+ tree tm_fn = get_global_binding (tm_ident);
if (!tm_fn)
tm_fn = push_library_fn (tm_ident, type, except, ecf | tm_ecf);
record_tm_replacement (res, tm_fn);
if (!throw_fn)
{
tree name = get_identifier ("__cxa_throw");
- throw_fn = IDENTIFIER_GLOBAL_VALUE (name);
+ throw_fn = get_global_binding (name);
if (!throw_fn)
{
/* Declare void __cxa_throw (void*, void*, void (*)(void*)). */
if (flag_tm)
{
tree itm_name = get_identifier ("_ITM_cxa_throw");
- tree itm_fn = IDENTIFIER_GLOBAL_VALUE (itm_name);
+ tree itm_fn = get_global_binding (itm_name);
if (!itm_fn)
itm_fn = push_throw_library_fn (itm_name, tmp);
apply_tm_attr (itm_fn, get_identifier ("transaction_pure"));
if (!rethrow_fn)
{
tree name = get_identifier ("__cxa_rethrow");
- rethrow_fn = IDENTIFIER_GLOBAL_VALUE (name);
+ rethrow_fn = get_global_binding (name);
if (!rethrow_fn)
/* Declare void __cxa_rethrow (void). */
rethrow_fn = push_throw_library_fn
{
tree name = get_identifier ("__cxa_throw_bad_array_new_length");
- fn = IDENTIFIER_GLOBAL_VALUE (name);
+ fn = get_global_binding (name);
if (!fn)
fn = push_throw_library_fn
(name, build_function_type_list (sizetype, NULL_TREE));
return ret;
}
-
-/* Return the IDENTIFIER_GLOBAL_VALUE of T, for use in common code, since
- the definition of IDENTIFIER_GLOBAL_VALUE is different for C and C++. */
-
-tree
-identifier_global_value (tree t)
-{
- return IDENTIFIER_GLOBAL_VALUE (t);
-}
-
/* Push a definition of struct, union or enum tag named ID. into
binding_level B. DECL is a TYPE_DECL for the type. We assume that
the tag ID is not already defined. */
return ret;
}
-/* Set value binding of NAME in the global namespace to VAL. Does not
- add it to the list of things in the namespace. */
+/* Push internal DECL into the global namespace. Does not do the
+ full overload fn handling and does not add it to the list of things
+ in the namespace. */
void
-set_global_binding (tree name, tree val)
+set_global_binding (tree decl)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- gcc_checking_assert (name == DECL_NAME (val));
- tree *slot = find_namespace_slot (global_namespace, name, true);
+ tree *slot = find_namespace_slot (global_namespace, DECL_NAME (decl), true);
tree old = MAYBE_STAT_DECL (*slot);
if (!old)
- *slot = val;
- else if (old == val)
+ *slot = decl;
+ else if (old == decl)
;
else if (!STAT_HACK_P (*slot)
- && TREE_CODE (val) == TYPE_DECL && DECL_ARTIFICIAL (val))
- *slot = stat_hack (old, val);
+ && TREE_CODE (decl) == TYPE_DECL && DECL_ARTIFICIAL (decl))
+ *slot = stat_hack (old, decl);
else if (!STAT_HACK_P (*slot)
&& TREE_CODE (old) == TYPE_DECL && DECL_ARTIFICIAL (old))
- *slot = stat_hack (val, old);
+ *slot = stat_hack (decl, old);
else
/* The user's placed something in the implementor's
namespace. */
- diagnose_name_conflict (val, old);
+ diagnose_name_conflict (decl, old);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
CURRENT_BINDING_LEVEL. You should use lookup_name_current_level
instead. */
-/* Note that the information in the `names' component of the global contour
- is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */
-
struct GTY(()) cp_binding_level {
/* A chain of _DECL nodes for all variables, constants, functions,
and typedef types. These are in the reverse of the order
extern tree lookup_name_real (tree, int, int, bool, int, int);
extern tree lookup_type_scope (tree, tag_scope);
extern tree get_namespace_binding (tree ns, tree id);
-extern void set_global_binding (tree id, tree val);
+extern void set_global_binding (tree decl);
+inline tree get_global_binding (tree id)
+{
+ return get_namespace_binding (NULL_TREE, id);
+}
extern tree lookup_qualified_name (tree, tree, int, bool, /*hidden*/bool = false);
extern tree lookup_name_nonclass (tree);
extern bool is_local_extern (tree);
type_info objects for static initialization.
The type information VAR_DECL of a type is held on the
- IDENTIFIER_GLOBAL_VALUE of the type's mangled name. That VAR_DECL
+ get_global_binding of the type's mangled name. That VAR_DECL
will be the internal type. It will usually have the correct
internal type reflecting the kind of type it represents (pointer,
array, function, class, inherited class, etc). When the type it
if (!fn)
{
tree name = get_identifier ("__cxa_bad_cast");
- fn = IDENTIFIER_GLOBAL_VALUE (name);
+ fn = get_global_binding (name);
if (!fn)
fn = push_throw_library_fn
(name, build_function_type_list (ptr_type_node, NULL_TREE));
if (!fn)
{
tree name = get_identifier ("__cxa_bad_typeid");
- fn = IDENTIFIER_GLOBAL_VALUE (name);
+ fn = get_global_binding (name);
if (!fn)
{
tree t = build_reference_type (const_type_info_type_node);
name = mangle_typeinfo_for_type (type);
- d = IDENTIFIER_GLOBAL_VALUE (name);
+ d = get_global_binding (name);
if (!d)
{
int ix = get_pseudo_ti_index (type);