Skip to content

Commit b7222de

Browse files
committed
Use goto_programt::loop_id
This ensures we build loop identifiers in the same way everywhere.
1 parent 3d2efc0 commit b7222de

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/goto-instrument/unwind.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ void goto_unwindt::unwind(
288288
}
289289

290290
PRECONDITION(!function_id.empty());
291-
const irep_idt loop_id =
292-
id2string(function_id) + "." + std::to_string(i_it->loop_number);
291+
const irep_idt loop_id = goto_programt::loop_id(function_id, *i_it);
293292

294293
auto limit=unwindset.get_limit(loop_id, 0);
295294

src/goto-programs/loop_ids.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ void show_loop_ids(
3636
{
3737
if(it->is_backwards_goto())
3838
{
39-
unsigned loop_id=it->loop_number;
40-
41-
std::cout << "Loop " << function_identifier << "." << loop_id << ":"
39+
std::cout << "Loop "
40+
<< goto_programt::loop_id(function_identifier, *it) << ":"
4241
<< "\n";
4342

4443
std::cout << " " << it->source_location << "\n";
@@ -53,9 +52,8 @@ void show_loop_ids(
5352
{
5453
if(it->is_backwards_goto())
5554
{
56-
unsigned loop_id=it->loop_number;
5755
std::string id =
58-
id2string(function_identifier) + "." + std::to_string(loop_id);
56+
id2string(goto_programt::loop_id(function_identifier, *it));
5957

6058
xmlt xml_loop("loop", {{"name", id}}, {});
6159
xml_loop.new_element("loop-id").data=id;
@@ -82,9 +80,8 @@ void show_loop_ids_json(
8280
{
8381
if(it->is_backwards_goto())
8482
{
85-
unsigned loop_id=it->loop_number;
8683
std::string id =
87-
id2string(function_identifier) + "." + std::to_string(loop_id);
84+
id2string(goto_programt::loop_id(function_identifier, *it));
8885

8986
loops.push_back(
9087
json_objectt({{"name", json_stringt(id)},

0 commit comments

Comments
 (0)