Commit 4fef8379 by Martin Liska Committed by Martin Liska

Change use to type-based pool allocator in c-format.c.

	* c-format.c (check_format_arg):Use new type-based pool allocator.
	(check_format_info_main) Likewise.

From-SVN: r223949
parent c1f5ce48
2015-06-01 Martin Liska <mliska@suse.cz>
* c-format.c (check_format_arg):Use new type-based pool allocator.
(check_format_info_main) Likewise.
2015-05-31 Eric Botcazou <ebotcazou@adacore.com> 2015-05-31 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (is_tagged_type): Test for TYPE_METHODS on main variant. * c-ada-spec.c (is_tagged_type): Test for TYPE_METHODS on main variant.
......
...@@ -191,7 +191,7 @@ handle_format_arg_attribute (tree *node, tree ARG_UNUSED (name), ...@@ -191,7 +191,7 @@ handle_format_arg_attribute (tree *node, tree ARG_UNUSED (name),
if (prototype_p (type)) if (prototype_p (type))
{ {
/* The format arg can be any string reference valid for the language and /* The format arg can be any string reference valid for the language and
target. We cannot be more specific in this case. */ target. We cannot be more specific in this case. */
if (!check_format_string (type, format_num, flags, no_add_attrs, -1)) if (!check_format_string (type, format_num, flags, no_add_attrs, -1))
return NULL_TREE; return NULL_TREE;
} }
...@@ -1031,7 +1031,8 @@ static void check_format_arg (void *, tree, unsigned HOST_WIDE_INT); ...@@ -1031,7 +1031,8 @@ static void check_format_arg (void *, tree, unsigned HOST_WIDE_INT);
static void check_format_info_main (format_check_results *, static void check_format_info_main (format_check_results *,
function_format_info *, function_format_info *,
const char *, int, tree, const char *, int, tree,
unsigned HOST_WIDE_INT, alloc_pool); unsigned HOST_WIDE_INT,
pool_allocator<format_wanted_type> &);
static void init_dollar_format_checking (int, tree); static void init_dollar_format_checking (int, tree);
static int maybe_read_dollar_number (const char **, int, static int maybe_read_dollar_number (const char **, int,
...@@ -1518,7 +1519,6 @@ check_format_arg (void *ctx, tree format_tree, ...@@ -1518,7 +1519,6 @@ check_format_arg (void *ctx, tree format_tree,
const char *format_chars; const char *format_chars;
tree array_size = 0; tree array_size = 0;
tree array_init; tree array_init;
alloc_pool fwt_pool;
if (TREE_CODE (format_tree) == VAR_DECL) if (TREE_CODE (format_tree) == VAR_DECL)
{ {
...@@ -1587,7 +1587,7 @@ check_format_arg (void *ctx, tree format_tree, ...@@ -1587,7 +1587,7 @@ check_format_arg (void *ctx, tree format_tree,
{ {
bool objc_str = (info->format_type == gcc_objc_string_format_type); bool objc_str = (info->format_type == gcc_objc_string_format_type);
/* We cannot examine this string here - but we can check that it is /* We cannot examine this string here - but we can check that it is
a valid type. */ a valid type. */
if (TREE_CODE (format_tree) != CONST_DECL if (TREE_CODE (format_tree) != CONST_DECL
|| !((objc_str && objc_string_ref_type_p (TREE_TYPE (format_tree))) || !((objc_str && objc_string_ref_type_p (TREE_TYPE (format_tree)))
|| (*targetcm.string_object_ref_type_p) || (*targetcm.string_object_ref_type_p)
...@@ -1605,9 +1605,9 @@ check_format_arg (void *ctx, tree format_tree, ...@@ -1605,9 +1605,9 @@ check_format_arg (void *ctx, tree format_tree,
++arg_num; ++arg_num;
} }
/* So, we have a valid literal string object and one or more params. /* So, we have a valid literal string object and one or more params.
We need to use an external helper to parse the string into format We need to use an external helper to parse the string into format
info. For Objective-C variants we provide the resource within the info. For Objective-C variants we provide the resource within the
objc tree, for target variants, via a hook. */ objc tree, for target variants, via a hook. */
if (objc_str) if (objc_str)
objc_check_format_arg (format_tree, params); objc_check_format_arg (format_tree, params);
else if (targetcm.check_string_object_format_arg) else if (targetcm.check_string_object_format_arg)
...@@ -1694,11 +1694,9 @@ check_format_arg (void *ctx, tree format_tree, ...@@ -1694,11 +1694,9 @@ check_format_arg (void *ctx, tree format_tree,
will decrement it if it finds there are extra arguments, but this way will decrement it if it finds there are extra arguments, but this way
need not adjust it for every return. */ need not adjust it for every return. */
res->number_other++; res->number_other++;
fwt_pool = create_alloc_pool ("format_wanted_type pool", pool_allocator <format_wanted_type> fwt_pool ("format_wanted_type pool", 10);
sizeof (format_wanted_type), 10);
check_format_info_main (res, info, format_chars, format_length, check_format_info_main (res, info, format_chars, format_length,
params, arg_num, fwt_pool); params, arg_num, fwt_pool);
free_alloc_pool (fwt_pool);
} }
...@@ -1713,7 +1711,8 @@ static void ...@@ -1713,7 +1711,8 @@ static void
check_format_info_main (format_check_results *res, check_format_info_main (format_check_results *res,
function_format_info *info, const char *format_chars, function_format_info *info, const char *format_chars,
int format_length, tree params, int format_length, tree params,
unsigned HOST_WIDE_INT arg_num, alloc_pool fwt_pool) unsigned HOST_WIDE_INT arg_num,
pool_allocator<format_wanted_type> &fwt_pool)
{ {
const char *orig_format_chars = format_chars; const char *orig_format_chars = format_chars;
tree first_fillin_param = params; tree first_fillin_param = params;
...@@ -2424,8 +2423,7 @@ check_format_info_main (format_check_results *res, ...@@ -2424,8 +2423,7 @@ check_format_info_main (format_check_results *res,
fci = fci->chain; fci = fci->chain;
if (fci) if (fci)
{ {
wanted_type_ptr = (format_wanted_type *) wanted_type_ptr = fwt_pool.allocate ();
pool_alloc (fwt_pool);
arg_num++; arg_num++;
wanted_type = *fci->types[length_chars_val].type; wanted_type = *fci->types[length_chars_val].type;
wanted_type_name = fci->types[length_chars_val].name; wanted_type_name = fci->types[length_chars_val].name;
......
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