]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Used `IndexVec` for place_map
authorKushal Pal <kushalpal109@gmail.com>
Wed, 28 Aug 2024 06:39:28 +0000 (06:39 +0000)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Mon, 9 Sep 2024 08:33:02 +0000 (08:33 +0000)
gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Use strong
type instead of size_t.
(Dump::visit_place): Likewise.
(Dump::visit_scope): Likewise.
* checks/errors/borrowck/rust-bir-dump.h (class Dump): Use
IndeVec for place_map.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
gcc/rust/checks/errors/borrowck/rust-bir-dump.h

index 080029ac9d9e4364ee64aabc3516d05171257f88..abc45a84d0a87b7c15fbada662ce1eebdf46333e 100644 (file)
@@ -121,9 +121,9 @@ Dump::go (bool enable_simplify_cfg)
     {
       bb_fold_map[i] = i;
     }
-  for (size_t i = 0; i < place_map.size (); ++i)
+  for (PlaceId i = INVALID_PLACE; i.value < place_map.size (); ++i.value)
     {
-      place_map[i] = {i};
+      place_map[i] = i;
     }
 
   if (enable_simplify_cfg)
@@ -133,7 +133,7 @@ Dump::go (bool enable_simplify_cfg)
 
   stream << "fn " << name << "(";
   print_comma_separated (stream, func.arguments, [this] (PlaceId place_id) {
-    stream << "_" << place_map[place_id.value].value << ": "
+    stream << "_" << place_map[place_id].value << ": "
           << get_tyty_name (func.place_db[place_id].tyty);
   });
   stream << ") -> " << get_tyty_name (func.place_db[RETURN_VALUE_PLACE].tyty);
@@ -245,7 +245,7 @@ Dump::visit_place (PlaceId place_id)
     {
     case Place::TEMPORARY:
     case Place::VARIABLE:
-      stream << "_" << place_map[place_id.value].value;
+      stream << "_" << place_map[place_id].value;
       break;
     case Place::DEREF:
       stream << "(";
@@ -382,7 +382,7 @@ Dump::visit_scope (ScopeId id, size_t depth)
   for (auto &local : scope.locals)
     {
       indent (depth + 1) << "let _";
-      stream << place_map[local.value].value << ": "
+      stream << place_map[local].value << ": "
             << get_tyty_name (func.place_db[local].tyty);
       stream << ";\t";
 
index 4f2bb2acd8febd8b7b373c8aeaf31e8b4e6abc44..63efb59f00623fc9f225e1d70d5afc88feb87909 100644 (file)
@@ -35,7 +35,7 @@ class Dump : public Visitor
   const std::string &name;
 
   IndexVec<BasicBlockId, BasicBlockId> bb_fold_map;
-  std::vector<PlaceId> place_map;
+  IndexVec<PlaceId, PlaceId> place_map;
 
   PlaceId statement_place = INVALID_PLACE;
   BasicBlockId statement_bb = INVALID_BB;