@@ -15,6 +15,8 @@ Author: Peter Schrammel
15
15
16
16
std::ostream &goto_difft::output_functions (std::ostream &out) const
17
17
{
18
+ namespacet ns1 (goto_model1.symbol_table );
19
+ namespacet ns2 (goto_model2.symbol_table );
18
20
switch (ui)
19
21
{
20
22
case ui_message_handlert::uit::PLAIN:
@@ -24,33 +26,24 @@ std::ostream &goto_difft::output_functions(std::ostream &out) const
24
26
for (irep_id_sett::const_iterator it=new_functions.begin ();
25
27
it!=new_functions.end (); ++it)
26
28
{
27
- const goto_programt &program=
28
- goto_model2.goto_functions .function_map .at (*it).body ;
29
- out << " "
30
- << program.instructions .begin ()->source_location .get_file ()
31
- << " : " << *it << " \n " ;
29
+ const symbolt &symbol = ns2.lookup (*it);
30
+ out << " " << symbol.location .get_file () << " : " << *it << " \n " ;
32
31
}
33
32
34
33
out << " modified functions:\n " ;
35
34
for (irep_id_sett::const_iterator it=modified_functions.begin ();
36
35
it!=modified_functions.end (); ++it)
37
36
{
38
- const goto_programt &program=
39
- goto_model2.goto_functions .function_map .at (*it).body ;
40
- out << " "
41
- << program.instructions .begin ()->source_location .get_file ()
42
- << " : " << *it << " \n " ;
37
+ const symbolt &symbol = ns2.lookup (*it);
38
+ out << " " << symbol.location .get_file () << " : " << *it << " \n " ;
43
39
}
44
40
45
41
out << " deleted functions:\n " ;
46
42
for (irep_id_sett::const_iterator it=deleted_functions.begin ();
47
43
it!=deleted_functions.end (); ++it)
48
44
{
49
- const goto_programt &program=
50
- goto_model1.goto_functions .function_map .at (*it).body ;
51
- out << " "
52
- << program.instructions .begin ()->source_location .get_file ()
53
- << " : " << *it << " \n " ;
45
+ const symbolt &symbol = ns1.lookup (*it);
46
+ out << " " << symbol.location .get_file () << " : " << *it << " \n " ;
54
47
}
55
48
break ;
56
49
}
@@ -91,12 +84,22 @@ void goto_difft::convert_function(
91
84
json_objectt &result,
92
85
const irep_idt &function_name) const
93
86
{
94
- const goto_programt &program=
95
- goto_model2.goto_functions .function_map .at (function_name).body ;
96
- if (!program.instructions .empty ())
87
+ // the function may be in goto_model1 or goto_model2
88
+ if (
89
+ goto_model1.goto_functions .function_map .find (function_name) !=
90
+ goto_model1.goto_functions .function_map .end ())
97
91
{
98
- result[" sourceLocation" ]=
99
- json (program.instructions .begin ()->source_location );
92
+ const symbolt &symbol =
93
+ namespacet (goto_model1.symbol_table ).lookup (function_name);
94
+ result[" sourceLocation" ] = json (symbol.location );
95
+ }
96
+ else if (
97
+ goto_model2.goto_functions .function_map .find (function_name) !=
98
+ goto_model2.goto_functions .function_map .end ())
99
+ {
100
+ const symbolt &symbol =
101
+ namespacet (goto_model2.symbol_table ).lookup (function_name);
102
+ result[" sourceLocation" ] = json (symbol.location );
100
103
}
101
104
result[" name" ]=json_stringt (id2string (function_name));
102
105
}
0 commit comments