Commit c405923d by Nathan Sidwell Committed by Nathan Sidwell

name-lookup.c (pushdecl_top_level) pushdecl_top_level_and_finish): Move after…

name-lookup.c (pushdecl_top_level) pushdecl_top_level_and_finish): Move after namespace pushing and popping functions.

	* name-lookup.c (pushdecl_top_level)
	pushdecl_top_level_and_finish): Move after namespace pushing and
	popping functions.
	(push_to_top_level): Rename to ...
	(do_push_to_top_level): ... here.  Remove timing code.
	(pop_from_top_level_1): Rename to ...
	(do_pop_from_top_level): ... here.
	(do_push_nested_namespace, do_pop_nested_namespace)
	(push_to_top_level): New wrapper for do_push_to_top_level.
	(pop_from_top_level): Adjust.
	(push_nested_namepace, pop_nested_namespace): Wrappers for workers.
(--This line, and those below, will be ignored--

M    cp/ChangeLog
M    cp/name-lookup.c

From-SVN: r248327
parent 0c4f8178
2017-05-22 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (pushdecl_top_level,
pushdecl_top_level_and_finish): Move after namespace pushing and
popping functions.
(push_to_top_level): Rename to ...
(do_push_to_top_level): ... here. Remove timing code.
(pop_from_top_level_1): Rename to ...
(do_pop_from_top_level): ... here.
(do_push_nested_namespace, do_pop_nested_namespace)
(push_to_top_level): New wrapper for do_push_to_top_level.
(pop_from_top_level): Adjust.
(push_nested_namepace, pop_nested_namespace): Wrappers for workers.
2017-05-19 Bernd Edlinger <bernd.edlinger@hotmail.de> 2017-05-19 Bernd Edlinger <bernd.edlinger@hotmail.de>
* config-lang.in (gtfiles): Add c-family/c-format.c, * config-lang.in (gtfiles): Add c-family/c-format.c,
......
...@@ -4491,32 +4491,6 @@ parse_using_directive (tree name_space, tree attribs) ...@@ -4491,32 +4491,6 @@ parse_using_directive (tree name_space, tree attribs)
} }
} }
/* Pushes X into the global namespace. */
tree
pushdecl_top_level (tree x, bool is_friend)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
push_to_top_level ();
x = pushdecl_namespace_level (x, is_friend);
pop_from_top_level ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return x;
}
/* Pushes X into the global namespace and Calls cp_finish_decl to
register the variable, initializing it with INIT. */
tree
pushdecl_top_level_and_finish (tree x, tree init)
{
push_to_top_level ();
x = pushdecl_namespace_level (x, false);
cp_finish_decl (x, init, false, NULL_TREE, 0);
pop_from_top_level ();
return x;
}
/* Combines two sets of overloaded functions into an OVERLOAD chain, removing /* Combines two sets of overloaded functions into an OVERLOAD chain, removing
duplicates. The first list becomes the tail of the result. duplicates. The first list becomes the tail of the result.
...@@ -6232,8 +6206,8 @@ store_class_bindings (vec<cp_class_binding, va_gc> *names, ...@@ -6232,8 +6206,8 @@ store_class_bindings (vec<cp_class_binding, va_gc> *names,
static GTY((deletable)) struct saved_scope *free_saved_scope; static GTY((deletable)) struct saved_scope *free_saved_scope;
void static void
push_to_top_level (void) do_push_to_top_level (void)
{ {
struct saved_scope *s; struct saved_scope *s;
cp_binding_level *b; cp_binding_level *b;
...@@ -6241,8 +6215,6 @@ push_to_top_level (void) ...@@ -6241,8 +6215,6 @@ push_to_top_level (void)
size_t i; size_t i;
bool need_pop; bool need_pop;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
/* Reuse or create a new structure for this saved scope. */ /* Reuse or create a new structure for this saved scope. */
if (free_saved_scope != NULL) if (free_saved_scope != NULL)
{ {
...@@ -6316,11 +6288,10 @@ push_to_top_level (void) ...@@ -6316,11 +6288,10 @@ push_to_top_level (void)
push_class_stack (); push_class_stack ();
cp_unevaluated_operand = 0; cp_unevaluated_operand = 0;
c_inhibit_evaluation_warnings = 0; c_inhibit_evaluation_warnings = 0;
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
} }
static void static void
pop_from_top_level_1 (void) do_pop_from_top_level (void)
{ {
struct saved_scope *s = scope_chain; struct saved_scope *s = scope_chain;
cxx_saved_binding *saved; cxx_saved_binding *saved;
...@@ -6356,14 +6327,68 @@ pop_from_top_level_1 (void) ...@@ -6356,14 +6327,68 @@ pop_from_top_level_1 (void)
free_saved_scope = s; free_saved_scope = s;
} }
/* Wrapper for pop_from_top_level_1. */ /* Push into the scope of the namespace NS, even if it is deeply
nested within another namespace. */
void static void
pop_from_top_level (void) do_push_nested_namespace (tree ns)
{
if (ns == global_namespace)
do_push_to_top_level ();
else
{
do_push_nested_namespace (CP_DECL_CONTEXT (ns));
gcc_checking_assert
(get_namespace_binding (current_namespace,
DECL_NAME (ns) ? DECL_NAME (ns)
: anon_identifier) == ns);
resume_scope (NAMESPACE_LEVEL (ns));
current_namespace = ns;
}
}
/* Pop back from the scope of the namespace NS, which was previously
entered with push_nested_namespace. */
static void
do_pop_nested_namespace (tree ns)
{
while (ns != global_namespace)
{
ns = CP_DECL_CONTEXT (ns);
current_namespace = ns;
leave_scope ();
}
do_pop_from_top_level ();
}
/* Pushes X into the global namespace. */
tree
pushdecl_top_level (tree x, bool is_friend)
{ {
bool subtime = timevar_cond_start (TV_NAME_LOOKUP); bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
pop_from_top_level_1 (); do_push_to_top_level ();
x = pushdecl_namespace_level (x, is_friend);
do_pop_from_top_level ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime); timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return x;
}
/* Pushes X into the global namespace and calls cp_finish_decl to
register the variable, initializing it with INIT. */
tree
pushdecl_top_level_and_finish (tree x, tree init)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
do_push_to_top_level ();
x = pushdecl_namespace_level (x, false);
cp_finish_decl (x, init, false, NULL_TREE, 0);
do_pop_from_top_level ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return x;
} }
/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, /* Push into the scope of the NAME namespace. If NAME is NULL_TREE,
...@@ -6490,41 +6515,46 @@ pop_namespace (void) ...@@ -6490,41 +6515,46 @@ pop_namespace (void)
leave_scope (); leave_scope ();
} }
/* Push into the scope of the namespace NS, even if it is deeply /* External entry points for do_{push_to/pop_from}_top_level. */
nested within another namespace. */
void void
push_nested_namespace (tree ns) push_to_top_level (void)
{ {
if (ns == global_namespace) bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
push_to_top_level (); do_push_to_top_level ();
else timevar_cond_stop (TV_NAME_LOOKUP, subtime);
{
push_nested_namespace (CP_DECL_CONTEXT (ns));
push_namespace (DECL_NAME (ns));
}
} }
/* Pop back from the scope of the namespace NS, which was previously /* Wrapper for pop_from_top_level_1. */
entered with push_nested_namespace. */
void
pop_from_top_level (void)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
do_pop_from_top_level ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
/* External entry points for do_{push,pop}_nested_namespace. */
void
push_nested_namespace (tree ns)
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
do_push_nested_namespace (ns);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
void void
pop_nested_namespace (tree ns) pop_nested_namespace (tree ns)
{ {
bool subtime = timevar_cond_start (TV_NAME_LOOKUP); bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
gcc_assert (current_namespace == ns); gcc_assert (current_namespace == ns);
while (ns != global_namespace) do_pop_nested_namespace (ns);
{
pop_namespace ();
ns = CP_DECL_CONTEXT (ns);
}
pop_from_top_level ();
timevar_cond_stop (TV_NAME_LOOKUP, subtime); timevar_cond_stop (TV_NAME_LOOKUP, subtime);
} }
/* Pop off extraneous binding levels left over due to syntax errors. /* Pop off extraneous binding levels left over due to syntax errors.
We don't pop past namespaces, as they might be valid. */ We don't pop past namespaces, as they might be valid. */
void void
......
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