diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-07-08 18:55:28 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-07-08 18:55:28 -0400 |
commit | 113b5ce0610207717f651a3f8a3f1123d93f97af (patch) | |
tree | 68bdf48caf815f5df408a7b9a0b6026f635b2d1a /gcc | |
parent | 2b3027bea3f218599d36379d3d593841df7a1559 (diff) | |
download | gcc-113b5ce0610207717f651a3f8a3f1123d93f97af.zip gcc-113b5ce0610207717f651a3f8a3f1123d93f97af.tar.gz gcc-113b5ce0610207717f651a3f8a3f1123d93f97af.tar.bz2 |
c-format.cc: add ctors to format_check_results and format_check_context
This is a minor cleanup I spotted whilst working on another patch.
No functional change intended.
gcc/c-family/ChangeLog:
* c-format.cc (format_check_results::format_check_results): New
ctor.
(struct format_check_context): Add ctor; add "m_" prefix to all
fields.
(check_format_info): Use above ctors.
(check_format_arg): Update for "m_" prefix to
format_check_context.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/c-format.cc | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc index 7a5ffc2..5bfd2fc 100644 --- a/gcc/c-family/c-format.cc +++ b/gcc/c-family/c-format.cc @@ -1021,6 +1021,20 @@ static int n_format_types = ARRAY_SIZE (format_types_orig); many leaves resulting from nested conditional expressions. */ struct format_check_results { + format_check_results (location_t format_string_loc_) + : number_non_literal (0), + number_extra_args (0), + extra_arg_loc (UNKNOWN_LOCATION), + number_dollar_extra_args (0), + number_wide (0), + number_non_char (0), + number_empty (0), + number_unterminated (0), + number_other (0), + format_string_loc (format_string_loc_) + { + } + /* Number of leaves of the format argument that could not be checked as they were not string literals. */ int number_non_literal; @@ -1050,10 +1064,21 @@ struct format_check_results struct format_check_context { - format_check_results *res; - function_format_info *info; - tree params; - vec<location_t> *arglocs; + format_check_context (format_check_results *res, + function_format_info *info, + tree params, + vec<location_t> *arglocs) + : m_res (res), + m_info (info), + m_params (params), + m_arglocs (arglocs) + { + } + + format_check_results *m_res; + function_format_info *m_info; + tree m_params; + vec<location_t> *m_arglocs; }; /* Return the format name (as specified in the original table) for the format @@ -1539,10 +1564,8 @@ static void check_format_info (function_format_info *info, tree params, vec<location_t> *arglocs) { - format_check_context format_ctx; unsigned HOST_WIDE_INT arg_num; tree format_tree; - format_check_results res; /* Skip to format argument. If the argument isn't available, there's no work for us to do; prototype checking will catch the problem. */ for (arg_num = 1; ; ++arg_num) @@ -1558,26 +1581,14 @@ check_format_info (function_format_info *info, tree params, if (format_tree == 0) return; - res.number_non_literal = 0; - res.number_extra_args = 0; - res.extra_arg_loc = UNKNOWN_LOCATION; - res.number_dollar_extra_args = 0; - res.number_wide = 0; - res.number_non_char = 0; - res.number_empty = 0; - res.number_unterminated = 0; - res.number_other = 0; - res.format_string_loc = input_location; - - format_ctx.res = &res; - format_ctx.info = info; - format_ctx.params = params; - format_ctx.arglocs = arglocs; + format_check_results res (input_location); + + format_check_context format_ctx (&res, info, params, arglocs); check_function_arguments_recurse (check_format_arg, &format_ctx, format_tree, arg_num, OPT_Wformat_); - location_t loc = format_ctx.res->format_string_loc; + location_t loc = format_ctx.m_res->format_string_loc; if (res.number_non_literal > 0) { @@ -1659,10 +1670,10 @@ check_format_arg (void *ctx, tree format_tree, unsigned HOST_WIDE_INT arg_num) { format_check_context *format_ctx = (format_check_context *) ctx; - format_check_results *res = format_ctx->res; - function_format_info *info = format_ctx->info; - tree params = format_ctx->params; - vec<location_t> *arglocs = format_ctx->arglocs; + format_check_results *res = format_ctx->m_res; + function_format_info *info = format_ctx->m_info; + tree params = format_ctx->m_params; + vec<location_t> *arglocs = format_ctx->m_arglocs; int format_length; HOST_WIDE_INT offset; |