Skip to content

Commit

Permalink
Used IndexVec for place_map
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
braw-lee authored and P-E-P committed Sep 9, 2024
1 parent 4a6cccf commit 65b00cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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 << "(";
Expand Down Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/checks/errors/borrowck/rust-bir-dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 65b00cc

Please sign in to comment.