Commit 3c9feefc by Nathan Sidwell Committed by Nathan Sidwell

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
parent 5596d26a
2017-05-26 Nathan Sidwell <nathan@acm.org> 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. * call.c (build_operator_new_call): Do namelookup and ADL here.
(build_new_op_1): Likewise. (build_new_op_1): Likewise.
* name-lookup.h (lookup_function_nonclass): Delete declaration. * name-lookup.h (lookup_function_nonclass): Delete declaration.
......
...@@ -2546,7 +2546,11 @@ struct GTY(()) lang_decl_fn { ...@@ -2546,7 +2546,11 @@ struct GTY(()) lang_decl_fn {
struct GTY(()) lang_decl_ns { struct GTY(()) lang_decl_ns {
struct lang_decl_base base; struct lang_decl_base base;
cp_binding_level *level; 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. */ /* DECL_LANG_SPECIFIC for parameters. */
...@@ -3133,10 +3137,13 @@ struct GTY(()) lang_decl { ...@@ -3133,10 +3137,13 @@ struct GTY(()) lang_decl {
#define DECL_NAMESPACE_INLINE_P(NODE) \ #define DECL_NAMESPACE_INLINE_P(NODE) \
TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE)) TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
/* For a NAMESPACE_DECL: the list of using namespace directives /* In a NAMESPACE_DECL, a vector of using directives. */
The PURPOSE is the used namespace, the value is the namespace #define DECL_NAMESPACE_USING(NODE) \
that is the common ancestor. */ (LANG_DECL_NS_CHECK (NODE)->usings)
#define DECL_NAMESPACE_USING(NODE) (LANG_DECL_NS_CHECK (NODE)->ns_using)
/* 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 /* In a NAMESPACE_DECL, points to the original namespace if this is
a namespace alias. */ a namespace alias. */
......
...@@ -220,8 +220,10 @@ private: ...@@ -220,8 +220,10 @@ private:
private: private:
using_queue *queue_namespace (using_queue *queue, int depth, tree scope); 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 *do_queue_usings (using_queue *queue, int depth,
using_queue *queue_usings (using_queue *queue, int depth, tree usings) vec<tree, va_gc> *usings);
using_queue *queue_usings (using_queue *queue, int depth,
vec<tree, va_gc> *usings)
{ {
if (usings) if (usings)
queue = do_queue_usings (queue, depth, usings); queue = do_queue_usings (queue, depth, usings);
...@@ -496,11 +498,10 @@ name_lookup::search_namespace (tree scope) ...@@ -496,11 +498,10 @@ name_lookup::search_namespace (tree scope)
/* Look in exactly namespace. */ /* Look in exactly namespace. */
bool found = search_namespace_only (scope); bool found = search_namespace_only (scope);
/* Look down into inline namespaces. */ /* Recursively look in its inline children. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces; if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
inner; inner = TREE_CHAIN (inner)) for (unsigned ix = inlinees->length (); ix--;)
if (DECL_NAMESPACE_INLINE_P (inner)) found |= search_namespace ((*inlinees)[ix]);
found |= search_namespace (inner);
if (found) if (found)
mark_found (scope); mark_found (scope);
...@@ -520,17 +521,14 @@ name_lookup::search_usings (tree scope) ...@@ -520,17 +521,14 @@ name_lookup::search_usings (tree scope)
return true; return true;
bool found = false; bool found = false;
if (vec<tree, va_gc> *usings = DECL_NAMESPACE_USING (scope))
/* Look in direct usings. */ for (unsigned ix = usings->length (); ix--;)
for (tree usings = DECL_NAMESPACE_USING (scope); found |= search_qualified ((*usings)[ix], true);
usings; usings = TREE_CHAIN (usings))
found |= search_qualified (TREE_PURPOSE (usings), true);
/* Look in its inline children. */ /* Look in its inline children. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces; if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
inner; inner = TREE_CHAIN (inner)) for (unsigned ix = inlinees->length (); ix--;)
if (DECL_NAMESPACE_INLINE_P (inner)) found |= search_usings ((*inlinees)[ix]);
found |= search_usings (inner);
if (found) if (found)
mark_found (scope); mark_found (scope);
...@@ -580,10 +578,9 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree scope) ...@@ -580,10 +578,9 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree scope)
vec_safe_push (queue, using_pair (common, scope)); vec_safe_push (queue, using_pair (common, scope));
/* Queue its inline children. */ /* Queue its inline children. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces; if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
inner; inner = TREE_CHAIN (inner)) for (unsigned ix = inlinees->length (); ix--;)
if (DECL_NAMESPACE_INLINE_P (inner)) queue = queue_namespace (queue, depth, (*inlinees)[ix]);
queue = queue_namespace (queue, depth, inner);
/* Queue its using targets. */ /* Queue its using targets. */
queue = queue_usings (queue, depth, DECL_NAMESPACE_USING (scope)); queue = queue_usings (queue, depth, DECL_NAMESPACE_USING (scope));
...@@ -594,10 +591,11 @@ name_lookup::queue_namespace (using_queue *queue, int depth, tree 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. */ /* Add the namespaces in USINGS to the unqualified search queue. */
name_lookup::using_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)) for (unsigned ix = usings->length (); ix--;)
queue = queue_namespace (queue, depth, TREE_PURPOSE (usings)); queue = queue_namespace (queue, depth, (*usings)[ix]);
return queue; return queue;
} }
...@@ -686,10 +684,9 @@ name_lookup::adl_namespace_only (tree scope) ...@@ -686,10 +684,9 @@ name_lookup::adl_namespace_only (tree scope)
mark_seen (scope); mark_seen (scope);
/* Look down into inline namespaces. */ /* Look down into inline namespaces. */
for (tree inner = NAMESPACE_LEVEL (scope)->namespaces; if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
inner; inner = TREE_CHAIN (inner)) for (unsigned ix = inlinees->length (); ix--;)
if (DECL_NAMESPACE_INLINE_P (inner)) adl_namespace_only ((*inlinees)[ix]);
adl_namespace_only (inner);
if (cxx_binding *binding = find_namespace_binding (scope, name)) if (cxx_binding *binding = find_namespace_binding (scope, name))
add_fns (ovl_skip_hidden (binding->value)); add_fns (ovl_skip_hidden (binding->value));
...@@ -5962,13 +5959,14 @@ do_pop_nested_namespace (tree ns) ...@@ -5962,13 +5959,14 @@ do_pop_nested_namespace (tree ns)
the unqualified search. */ the unqualified search. */
static void 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 (usings)
if (target == TREE_PURPOSE (probe)) for (unsigned ix = usings->length (); ix--;)
if ((*usings)[ix] == target)
return; return;
usings = tree_cons (target, NULL_TREE, usings); vec_safe_push (usings, target);
} }
/* Tell the debug system of a using directive. */ /* Tell the debug system of a using directive. */
...@@ -6142,8 +6140,14 @@ push_namespace (tree name, bool make_inline) ...@@ -6142,8 +6140,14 @@ push_namespace (tree name, bool make_inline)
else if (TREE_PUBLIC (current_namespace)) else if (TREE_PUBLIC (current_namespace))
TREE_PUBLIC (ns) = 1; TREE_PUBLIC (ns) = 1;
if (name == anon_identifier || make_inline)
emit_debug_info_using_namespace (current_namespace, ns);
if (make_inline) 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) ...@@ -6171,10 +6175,14 @@ push_namespace (tree name, bool make_inline)
void void
pop_namespace (void) pop_namespace (void)
{ {
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
gcc_assert (current_namespace != global_namespace); gcc_assert (current_namespace != global_namespace);
current_namespace = CP_DECL_CONTEXT (current_namespace); current_namespace = CP_DECL_CONTEXT (current_namespace);
/* The binding level is not popped, as it might be re-opened later. */ /* The binding level is not popped, as it might be re-opened later. */
leave_scope (); leave_scope ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
} }
/* External entry points for do_{push_to/pop_from}_top_level. */ /* External entry points for do_{push_to/pop_from}_top_level. */
......
...@@ -194,9 +194,9 @@ struct GTY(()) cp_binding_level { ...@@ -194,9 +194,9 @@ struct GTY(()) cp_binding_level {
/* A list of USING_DECL nodes. */ /* A list of USING_DECL nodes. */
tree usings; tree usings;
/* A list of used namespaces. PURPOSE is the namespace,
VALUE the common ancestor with this binding_level's namespace. */ /* Using directives. */
tree using_directives; vec<tree, va_gc> *using_directives;
/* For the binding level corresponding to a class, the entities /* For the binding level corresponding to a class, the entities
declared in the class or its base classes. */ declared in the class or its base classes. */
......
2017-05-26 Nathan Sidwell <nathan@acm.org> 2017-05-26 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_make_namespace_inline): Push onto linees.
* libcp1plugin.cc (plugin_add_using_namespace): Call * libcp1plugin.cc (plugin_add_using_namespace): Call
finish_namespace_using_directive. finish_namespace_using_directive.
......
...@@ -934,6 +934,7 @@ plugin_make_namespace_inline (cc1_plugin::connection *) ...@@ -934,6 +934,7 @@ plugin_make_namespace_inline (cc1_plugin::connection *)
return 0; return 0;
DECL_NAMESPACE_INLINE_P (inline_ns) = true; DECL_NAMESPACE_INLINE_P (inline_ns) = true;
vec_safe_push (DECL_NAMESPACE_INLINEES (parent_ns), inline_ns);
return 1; return 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment