]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Clarify 'key_type_t' to 'location_t' as used for 'gcc/diagnostic-spec.h:nowarn_map'
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 31 Aug 2021 20:01:23 +0000 (22:01 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 13 Sep 2021 16:38:51 +0000 (18:38 +0200)
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.

gcc/diagnostic-spec.c
gcc/diagnostic-spec.h
gcc/warning-control.cc

index 5e961e1b9f9b3caab1f8ef093e3d0cd1ee2f9d38..eac5a3317c884b4d9016310157297923146b8715 100644 (file)
@@ -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;
 
index 4e4d260f74a3e56b3dddcebd564c7f81c6f149e2..9b3aaaa3ce673331fa17ca4118c8306bb6231d05 100644 (file)
@@ -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
index 9c506e163d676f2532862fdff52e7184a813d334..8d6c0828445fc34b00e4af0bf638481fcd7ab993 100644 (file)
@@ -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.  */