aboutsummaryrefslogtreecommitdiff
path: root/gcc/substring-locations.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-10-17 19:41:01 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-10-17 19:41:01 +0000
commit89b6abbb7e4ba154dc5dd2458cd3ea93ddabd800 (patch)
tree6ce19e9d8c4044bd590ad1020c56f9554ed8559c /gcc/substring-locations.c
parent9efb55ac054852c4ea4f082504363c2a66f41dfe (diff)
downloadgcc-89b6abbb7e4ba154dc5dd2458cd3ea93ddabd800.zip
gcc-89b6abbb7e4ba154dc5dd2458cd3ea93ddabd800.tar.gz
gcc-89b6abbb7e4ba154dc5dd2458cd3ea93ddabd800.tar.bz2
Simplify format_warning_at_substring API
The format_warning_at_substring API has a rather clunk way of indicating the location of the pertinent param (if any): a source_range * is passed in, which can be NULL. Doing so requires extracting a range from the location_t and passing around a pointer to it, or NULL, as needed. This patch simplifies things by eliminating the source_range * in favor of a location_t, with UNKNOWN_LOCATION used to signify that no param location is available. gcc/c-family/ChangeLog: * c-format.c (format_warning_at_char): Pass UNKNOWN_LOCATION rather than NULL to format_warning_va. (check_format_types): Likewise when calling format_type_warning. Remove code to extract source_ranges and source_range * in favor of just a location_t. (format_type_warning): Convert source_range * param to a location_t. gcc/ChangeLog: * gimple-ssa-sprintf.c (fmtwarn): Update for changed signature of format_warning_at_substring. (maybe_warn): Convert source_range * param to a location_t. Pass UNKNOWN_LOCATION rather than NULL to fmtwarn. (format_directive): Remove code to extract source_ranges and source_range * in favor of just a location_t. (parse_directive): Pass UNKNOWN_LOCATION rather than NULL to fmtwarn. * substring-locations.c (format_warning_va): Convert source_range * param to a location_t. (format_warning_at_substring): Likewise. * substring-locations.h (format_warning_va): Likewise. (format_warning_at_substring): Likewise. From-SVN: r253827
Diffstat (limited to 'gcc/substring-locations.c')
-rw-r--r--gcc/substring-locations.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/gcc/substring-locations.c b/gcc/substring-locations.c
index 433023d..095e5d0 100644
--- a/gcc/substring-locations.c
+++ b/gcc/substring-locations.c
@@ -63,7 +63,7 @@ along with GCC; see the file COPYING3. If not see
printf(fmt, msg);
^~~
- For each of cases 1-3, if param_range is non-NULL, then it is used
+ For each of cases 1-3, if param_loc is not UNKNOWN_LOCATION, then it is used
as a secondary range within the warning. For example, here it
is used with case 1:
@@ -100,7 +100,7 @@ along with GCC; see the file COPYING3. If not see
ATTRIBUTE_GCC_DIAG (5,0)
bool
format_warning_va (const substring_loc &fmt_loc,
- const source_range *param_range,
+ location_t param_loc,
const char *corrected_substring,
int opt, const char *gmsgid, va_list *ap)
{
@@ -136,13 +136,8 @@ format_warning_va (const substring_loc &fmt_loc,
rich_location richloc (line_table, primary_loc);
- if (param_range)
- {
- location_t param_loc = make_location (param_range->m_start,
- param_range->m_start,
- param_range->m_finish);
- richloc.add_range (param_loc, false);
- }
+ if (param_loc != UNKNOWN_LOCATION)
+ richloc.add_range (param_loc, false);
if (!err && corrected_substring && substring_within_range)
richloc.add_fixit_replace (fmt_substring_range, corrected_substring);
@@ -171,13 +166,13 @@ format_warning_va (const substring_loc &fmt_loc,
bool
format_warning_at_substring (const substring_loc &fmt_loc,
- const source_range *param_range,
+ location_t param_loc,
const char *corrected_substring,
int opt, const char *gmsgid, ...)
{
va_list ap;
va_start (ap, gmsgid);
- bool warned = format_warning_va (fmt_loc, param_range, corrected_substring,
+ bool warned = format_warning_va (fmt_loc, param_loc, corrected_substring,
opt, gmsgid, &ap);
va_end (ap);