re PR c++/48481 (C++ overloading memory hog)
PR c++/48481 * cp-tree.h (OVL_ARG_DEPENDENT): New. * name-lookup.c (add_function): Set it. * semantics.c (finish_call_expr): Free OVERLOADs if it's set. From-SVN: r172163
This commit is contained in:
parent
c9b558895e
commit
3a2cb4d037
|
@ -1,5 +1,10 @@
|
|||
2011-04-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/48481
|
||||
* cp-tree.h (OVL_ARG_DEPENDENT): New.
|
||||
* name-lookup.c (add_function): Set it.
|
||||
* semantics.c (finish_call_expr): Free OVERLOADs if it's set.
|
||||
|
||||
PR c++/48481
|
||||
* call.c (build_user_type_conversion_1): Use lookup_fnfields_slot.
|
||||
Release unused vector.
|
||||
|
|
|
@ -317,6 +317,9 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
|
|||
This is not to confuse with being used somewhere, which
|
||||
is not important for this node. */
|
||||
#define OVL_USED(NODE) TREE_USED (NODE)
|
||||
/* If set, this OVERLOAD was created for argument-dependent lookup
|
||||
and can be freed afterward. */
|
||||
#define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
|
||||
|
||||
struct GTY(()) tree_overload {
|
||||
struct tree_common common;
|
||||
|
|
|
@ -4725,7 +4725,11 @@ add_function (struct arg_lookup *k, tree fn)
|
|||
else if (fn == k->functions)
|
||||
;
|
||||
else
|
||||
k->functions = build_overload (fn, k->functions);
|
||||
{
|
||||
k->functions = build_overload (fn, k->functions);
|
||||
if (TREE_CODE (k->functions) == OVERLOAD)
|
||||
OVL_ARG_DEPENDENT (k->functions) = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2160,6 +2160,25 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
|
|||
result = convert_from_reference (result);
|
||||
}
|
||||
|
||||
if (koenig_p)
|
||||
{
|
||||
/* Free garbage OVERLOADs from arg-dependent lookup. */
|
||||
tree next = NULL_TREE;
|
||||
for (fn = orig_fn;
|
||||
fn && TREE_CODE (fn) == OVERLOAD && OVL_ARG_DEPENDENT (fn);
|
||||
fn = next)
|
||||
{
|
||||
if (processing_template_decl)
|
||||
/* In a template, we'll re-use them at instantiation time. */
|
||||
OVL_ARG_DEPENDENT (fn) = false;
|
||||
else
|
||||
{
|
||||
next = OVL_CHAIN (fn);
|
||||
ggc_free (fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue