aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2021-08-31 22:01:23 +0200
committerThomas Schwinge <thomas@codesourcery.com>2021-09-13 18:38:51 +0200
commit1985392242d9a6bf8b091f78143d3c1fa9ccd284 (patch)
treebb9669251850505aa0e4979dfad8ec173f820acb /gcc
parentaccf94329d61933e6c58c1d7815fb08d8fc2afa5 (diff)
downloadgcc-1985392242d9a6bf8b091f78143d3c1fa9ccd284.zip
gcc-1985392242d9a6bf8b091f78143d3c1fa9ccd284.tar.gz
gcc-1985392242d9a6bf8b091f78143d3c1fa9ccd284.tar.bz2
Clarify 'key_type_t' to 'location_t' as used for 'gcc/diagnostic-spec.h:nowarn_map'
To make it obvious what exactly the key type is. No change in behavior. gcc/ * diagnostic-spec.h (typedef xint_hash_t): Use 'location_t' instead of... (typedef key_type_t): ... this. Remove. (nowarn_map): Document. * diagnostic-spec.c (nowarn_map): Likewise. * warning-control.cc (convert_to_key): Evolve functions into... (get_location): ... these. Adjust all users.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/diagnostic-spec.c2
-rw-r--r--gcc/diagnostic-spec.h6
-rw-r--r--gcc/warning-control.cc41
3 files changed, 25 insertions, 24 deletions
diff --git a/gcc/diagnostic-spec.c b/gcc/diagnostic-spec.c
index 5e961e1..eac5a33 100644
--- a/gcc/diagnostic-spec.c
+++ b/gcc/diagnostic-spec.c
@@ -105,7 +105,7 @@ nowarn_spec_t::nowarn_spec_t (opt_code opt)
}
}
-/* Map from location to its no-warning disposition. */
+/* A mapping from a 'location_t' to the warning spec set for it. */
GTY(()) xint_hash_map_t *nowarn_map;
diff --git a/gcc/diagnostic-spec.h b/gcc/diagnostic-spec.h
index 4e4d260..9b3aaaa 100644
--- a/gcc/diagnostic-spec.h
+++ b/gcc/diagnostic-spec.h
@@ -130,12 +130,10 @@ operator!= (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
return !(lhs == rhs);
}
-typedef location_t key_type_t;
-typedef int_hash <key_type_t, 0, UINT_MAX> xint_hash_t;
+typedef int_hash <location_t, 0, UINT_MAX> xint_hash_t;
typedef hash_map<xint_hash_t, nowarn_spec_t> xint_hash_map_t;
-/* A mapping from the location of an expression to the warning spec
- set for it. */
+/* A mapping from a 'location_t' to the warning spec set for it. */
extern GTY(()) xint_hash_map_t *nowarn_map;
#endif // DIAGNOSTIC_SPEC_H_INCLUDED
diff --git a/gcc/warning-control.cc b/gcc/warning-control.cc
index 9c506e1..8d6c082 100644
--- a/gcc/warning-control.cc
+++ b/gcc/warning-control.cc
@@ -62,22 +62,22 @@ set_no_warning_bit (gimple *stmt, bool value)
stmt->no_warning = value;
}
-/* Return EXPR location or zero. */
+/* Return EXPR location or 'UNKNOWN_LOCATION'. */
-static inline key_type_t
-convert_to_key (const_tree expr)
+static inline location_t
+get_location (const_tree expr)
{
if (DECL_P (expr))
return DECL_SOURCE_LOCATION (expr);
if (EXPR_P (expr))
return EXPR_LOCATION (expr);
- return 0;
+ return UNKNOWN_LOCATION;
}
-/* Return STMT location (may be zero). */
+/* Return STMT location (may be 'UNKNOWN_LOCATION'). */
-static inline key_type_t
-convert_to_key (const gimple *stmt)
+static inline location_t
+get_location (const gimple *stmt)
{
return gimple_location (stmt);
}
@@ -87,12 +87,15 @@ convert_to_key (const gimple *stmt)
static nowarn_spec_t *
get_nowarn_spec (const_tree expr)
{
- const key_type_t key = convert_to_key (expr);
+ const location_t loc = get_location (expr);
- if (!get_no_warning_bit (expr) || !key)
+ if (loc == UNKNOWN_LOCATION)
return NULL;
- return nowarn_map ? nowarn_map->get (key) : NULL;
+ if (!get_no_warning_bit (expr))
+ return NULL;
+
+ return nowarn_map ? nowarn_map->get (loc) : NULL;
}
/* Return the no-warning bitmap for stateemt STMT. */
@@ -100,12 +103,12 @@ get_nowarn_spec (const_tree expr)
static nowarn_spec_t *
get_nowarn_spec (const gimple *stmt)
{
- const key_type_t key = convert_to_key (stmt);
+ const location_t loc = get_location (stmt);
if (!get_no_warning_bit (stmt))
return NULL;
- return nowarn_map ? nowarn_map->get (key) : NULL;
+ return nowarn_map ? nowarn_map->get (loc) : NULL;
}
/* Return true if warning OPT is suppressed for decl/expression EXPR.
@@ -153,9 +156,9 @@ suppress_warning (tree expr, opt_code opt /* = all_warnings */,
if (opt == no_warning)
return;
- const key_type_t key = convert_to_key (expr);
+ const location_t loc = get_location (expr);
- supp = suppress_warning_at (key, opt, supp) || supp;
+ supp = suppress_warning_at (loc, opt, supp) || supp;
set_no_warning_bit (expr, supp);
}
@@ -169,9 +172,9 @@ suppress_warning (gimple *stmt, opt_code opt /* = all_warnings */,
if (opt == no_warning)
return;
- const key_type_t key = convert_to_key (stmt);
+ const location_t loc = get_location (stmt);
- supp = suppress_warning_at (key, opt, supp) || supp;
+ supp = suppress_warning_at (loc, opt, supp) || supp;
set_no_warning_bit (stmt, supp);
}
@@ -181,7 +184,7 @@ suppress_warning (gimple *stmt, opt_code opt /* = all_warnings */,
template <class ToType, class FromType>
void copy_warning (ToType to, FromType from)
{
- const key_type_t to_key = convert_to_key (to);
+ const location_t to_loc = get_location (to);
if (nowarn_spec_t *from_map = get_nowarn_spec (from))
{
@@ -189,13 +192,13 @@ void copy_warning (ToType to, FromType from)
gcc_assert (get_no_warning_bit (from));
gcc_checking_assert (nowarn_map);
- nowarn_map->put (to_key, *from_map);
+ nowarn_map->put (to_loc, *from_map);
set_no_warning_bit (to, true);
}
else
{
if (nowarn_map)
- nowarn_map->remove (to_key);
+ nowarn_map->remove (to_loc);
/* The no-warning bit might be set even if there's no entry
in the map. */