Inline and using namespace representation change.

gcc/cp/
	Inline and using namespace representation change.
	* cp-tree.h (struct lang_decl_ns): Delete ns_using.  Add usings,
	inlinees as vector.
	(DECL_NAMESPACE_USING): Adjust.
	(DECL_NAMESPACE_INLINEES): New.
	* name-lookup.h (struct cp_binding_level): Change usings
	representation.
	* name-lookup.c (name_lookup::do_queue_usings)
	name_lookup::queue_usings): Adjust.
	(name_lookup::search_namespace, name_lookup::search_usings)
	name_lookup::queue_namespace): Adjust.
	(name_lookup::adl_namespace_only): Adjust.
	(add_using_namespace, push_namespace): Push onto vector.
	(pop_namespace): Add timing logic.

	libcc1/
	* libcp1plugin.cc (plugin_make_namespace_inline): Push onto linees.
((--This line, and those below, will be ignored--

M    gcc/cp/ChangeLog
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h
M    libcc1/libcp1plugin.cc
M    libcc1/ChangeLog

From-SVN: r248520
This commit is contained in:
Nathan Sidwell 2017-05-26 17:19:46 +00:00 committed by Nathan Sidwell
parent 5596d26a5c
commit 3c9feefc8d
6 changed files with 74 additions and 41 deletions

View File

@ -1,5 +1,20 @@
2017-05-26 Nathan Sidwell <nathan@acm.org>
Inline and using namespace representation change.
* cp-tree.h (struct lang_decl_ns): Delete ns_using. Add usings,
inlinees as vector.
(DECL_NAMESPACE_USING): Adjust.
(DECL_NAMESPACE_INLINEES): New.
* name-lookup.h (struct cp_binding_level): Change usings
representation.
* name-lookup.c (name_lookup::do_queue_usings,
name_lookup::queue_usings): Adjust.
(name_lookup::search_namespace, name_lookup::search_usings,
name_lookup::queue_namespace): Adjust.
(name_lookup::adl_namespace_only): Adjust.
(add_using_namespace, push_namespace): Push onto vector.
(pop_namespace): Add timing logic.
* call.c (build_operator_new_call): Do namelookup and ADL here.
(build_new_op_1): Likewise.
* name-lookup.h (lookup_function_nonclass): Delete declaration.

View File

@ -2546,7 +2546,11 @@ struct GTY(()) lang_decl_fn {
struct GTY(()) lang_decl_ns {
struct lang_decl_base base;
cp_binding_level *level;
tree ns_using;
/* using directives and inline children. These need to be va_gc,
because of PCH. */
vec<tree, va_gc> *usings;
vec<tree, va_gc> *inlinees;
};
/* DECL_LANG_SPECIFIC for parameters. */
@ -3133,10 +3137,13 @@ struct GTY(()) lang_decl {
#define DECL_NAMESPACE_INLINE_P(NODE) \
TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
/* For a NAMESPACE_DECL: the list of using namespace directives
The PURPOSE is the used namespace, the value is the namespace
that is the common ancestor. */
#define DECL_NAMESPACE_USING(NODE) (LANG_DECL_NS_CHECK (NODE)->ns_using)
/* In a NAMESPACE_DECL, a vector of using directives. */
#define DECL_NAMESPACE_USING(NODE) \
(LANG_DECL_NS_CHECK (NODE)->usings)
/* In a NAMESPACE_DECL, a vector of inline namespaces. */
#define DECL_NAMESPACE_INLINEES(NODE) \
(LANG_DECL_NS_CHECK (NODE)->inlinees)
/* In a NAMESPACE_DECL, points to the original namespace if this is
a namespace alias. */

View File

@ -220,8 +220,10 @@ private:
private:
using_queue *queue_namespace (using_queue *queue, int depth, tree scope);
using_queue *do_queue_usings (using_queue *queue, int depth, tree usings);
using_queue *queue_usings (using_queue *queue, int depth, tree usings)
using_queue *do_queue_usings (using_queue *queue, int depth,
vec<tree, va_gc> *usings);
using_queue *queue_usings (using_queue *queue, int depth,
vec<tree, va_gc> *usings)
{
if (usings)
queue = do_queue_usings (queue, depth, usings);
@ -496,11 +498,10 @@ name_lookup::search_namespace (tree scope)
/* Look in exactly namespace. */
bool found = search_namespace_only (scope);
/* Look down into inline namespaces. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces;
inner; inner = TREE_CHAIN (inner))
if (DECL_NAMESPACE_INLINE_P (inner))
found |= search_namespace (inner);
/* Recursively look in its inline children. */
if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
for (unsigned ix = inlinees->length (); ix--;)
found |= search_namespace ((*inlinees)[ix]);
if (found)
mark_found (scope);
@ -520,17 +521,14 @@ name_lookup::search_usings (tree scope)
return true;
bool found = false;
/* Look in direct usings. */
for (tree usings = DECL_NAMESPACE_USING (scope);
usings; usings = TREE_CHAIN (usings))
found |= search_qualified (TREE_PURPOSE (usings), true);
if (vec<tree, va_gc> *usings = DECL_NAMESPACE_USING (scope))
for (unsigned ix = usings->length (); ix--;)
found |= search_qualified ((*usings)[ix], true);
/* Look in its inline children. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces;
inner; inner = TREE_CHAIN (inner))
if (DECL_NAMESPACE_INLINE_P (inner))
found |= search_usings (inner);
if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
for (unsigned ix = inlinees->length (); ix--;)
found |= search_usings ((*inlinees)[ix]);
if (found)
mark_found (scope);
@ -580,10 +578,9 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree scope)
vec_safe_push (queue, using_pair (common, scope));
/* Queue its inline children. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces;
inner; inner = TREE_CHAIN (inner))
if (DECL_NAMESPACE_INLINE_P (inner))
queue = queue_namespace (queue, depth, inner);
if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
for (unsigned ix = inlinees->length (); ix--;)
queue = queue_namespace (queue, depth, (*inlinees)[ix]);
/* Queue its using targets. */
queue = queue_usings (queue, depth, DECL_NAMESPACE_USING (scope));
@ -594,10 +591,11 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree scope)
/* Add the namespaces in USINGS to the unqualified search queue. */
name_lookup::using_queue *
name_lookup::do_queue_usings (using_queue *queue, int depth, tree usings)
name_lookup::do_queue_usings (using_queue *queue, int depth,
vec<tree, va_gc> *usings)
{
for (; usings; usings = TREE_CHAIN (usings))
queue = queue_namespace (queue, depth, TREE_PURPOSE (usings));
for (unsigned ix = usings->length (); ix--;)
queue = queue_namespace (queue, depth, (*usings)[ix]);
return queue;
}
@ -686,10 +684,9 @@ name_lookup::adl_namespace_only (tree scope)
mark_seen (scope);
/* Look down into inline namespaces. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces;
inner; inner = TREE_CHAIN (inner))
if (DECL_NAMESPACE_INLINE_P (inner))
adl_namespace_only (inner);
if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
for (unsigned ix = inlinees->length (); ix--;)
adl_namespace_only ((*inlinees)[ix]);
if (cxx_binding *binding = find_namespace_binding (scope, name))
add_fns (ovl_skip_hidden (binding->value));
@ -5962,13 +5959,14 @@ do_pop_nested_namespace (tree ns)
the unqualified search. */
static void
add_using_namespace (tree &usings, tree target)
add_using_namespace (vec<tree, va_gc> *&usings, tree target)
{
for (tree probe = usings; probe; probe = TREE_CHAIN (probe))
if (target == TREE_PURPOSE (probe))
return;
if (usings)
for (unsigned ix = usings->length (); ix--;)
if ((*usings)[ix] == target)
return;
usings = tree_cons (target, NULL_TREE, usings);
vec_safe_push (usings, target);
}
/* Tell the debug system of a using directive. */
@ -6142,8 +6140,14 @@ push_namespace (tree name, bool make_inline)
else if (TREE_PUBLIC (current_namespace))
TREE_PUBLIC (ns) = 1;
if (name == anon_identifier || make_inline)
emit_debug_info_using_namespace (current_namespace, ns);
if (make_inline)
DECL_NAMESPACE_INLINE_P (ns) = true;
{
DECL_NAMESPACE_INLINE_P (ns) = true;
vec_safe_push (DECL_NAMESPACE_INLINEES (current_namespace), ns);
}
}
}
@ -6171,10 +6175,14 @@ push_namespace (tree name, bool make_inline)
void
pop_namespace (void)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
gcc_assert (current_namespace != global_namespace);
current_namespace = CP_DECL_CONTEXT (current_namespace);
/* The binding level is not popped, as it might be re-opened later. */
leave_scope ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
/* External entry points for do_{push_to/pop_from}_top_level. */

View File

@ -194,9 +194,9 @@ struct GTY(()) cp_binding_level {
/* A list of USING_DECL nodes. */
tree usings;
/* A list of used namespaces. PURPOSE is the namespace,
VALUE the common ancestor with this binding_level's namespace. */
tree using_directives;
/* Using directives. */
vec<tree, va_gc> *using_directives;
/* For the binding level corresponding to a class, the entities
declared in the class or its base classes. */

View File

@ -1,5 +1,7 @@
2017-05-26 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_make_namespace_inline): Push onto linees.
* libcp1plugin.cc (plugin_add_using_namespace): Call
finish_namespace_using_directive.

View File

@ -934,6 +934,7 @@ plugin_make_namespace_inline (cc1_plugin::connection *)
return 0;
DECL_NAMESPACE_INLINE_P (inline_ns) = true;
vec_safe_push (DECL_NAMESPACE_INLINEES (parent_ns), inline_ns);
return 1;
}