Skip to content

Commit c206a03

Browse files
authored
Merge pull request #3131 from diffblue/show_loop_ids_cleanup
Modest show_loop_ids cleanup
2 parents 7c483c1 + cc1c44c commit c206a03

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/goto-programs/loop_ids.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void show_loop_ids(
2727

2828
void show_loop_ids(
2929
ui_message_handlert::uit ui,
30+
const irep_idt &function_identifier,
3031
const goto_programt &goto_program)
3132
{
3233
switch(ui)
@@ -39,8 +40,8 @@ void show_loop_ids(
3940
{
4041
unsigned loop_id=it->loop_number;
4142

42-
std::cout << "Loop "
43-
<< it->function << "." << loop_id << ":" << "\n";
43+
std::cout << "Loop " << function_identifier << "." << loop_id << ":"
44+
<< "\n";
4445

4546
std::cout << " " << it->source_location << "\n";
4647
std::cout << "\n";
@@ -55,7 +56,8 @@ void show_loop_ids(
5556
if(it->is_backwards_goto())
5657
{
5758
unsigned loop_id=it->loop_number;
58-
std::string id=id2string(it->function)+"."+std::to_string(loop_id);
59+
std::string id =
60+
id2string(function_identifier) + "." + std::to_string(loop_id);
5961

6062
xmlt xml_loop("loop");
6163
xml_loop.set_attribute("name", id);
@@ -73,6 +75,7 @@ void show_loop_ids(
7375

7476
void show_loop_ids_json(
7577
ui_message_handlert::uit ui,
78+
const irep_idt &function_identifier,
7679
const goto_programt &goto_program,
7780
json_arrayt &loops)
7881
{
@@ -83,7 +86,8 @@ void show_loop_ids_json(
8386
if(it->is_backwards_goto())
8487
{
8588
unsigned loop_id=it->loop_number;
86-
std::string id=id2string(it->function)+"."+std::to_string(loop_id);
89+
std::string id =
90+
id2string(function_identifier) + "." + std::to_string(loop_id);
8791

8892
json_objectt &loop=loops.push_back().make_object();
8993
loop["name"]=json_stringt(id);
@@ -100,15 +104,16 @@ void show_loop_ids(
100104
{
101105
case ui_message_handlert::uit::PLAIN:
102106
case ui_message_handlert::uit::XML_UI:
103-
forall_goto_functions(it, goto_functions)
104-
show_loop_ids(ui, it->second.body);
107+
for(const auto &f: goto_functions.function_map)
108+
show_loop_ids(ui, f.first, f.second.body);
105109
break;
110+
106111
case ui_message_handlert::uit::JSON_UI:
107112
json_objectt json_result;
108113
json_arrayt &loops=json_result["loops"].make_array();
109114

110-
forall_goto_functions(it, goto_functions)
111-
show_loop_ids_json(ui, it->second.body, loops);
115+
for(const auto &f : goto_functions.function_map)
116+
show_loop_ids_json(ui, f.first, f.second.body, loops);
112117

113118
std::cout << ",\n" << json_result;
114119
break;

src/goto-programs/loop_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void show_loop_ids(
2626

2727
void show_loop_ids(
2828
ui_message_handlert::uit,
29+
const irep_idt &function_identifier,
2930
const goto_programt &);
3031

3132
#endif // CPROVER_GOTO_PROGRAMS_LOOP_IDS_H

0 commit comments

Comments
 (0)