@@ -27,15 +27,24 @@ class basic_blockst
27
27
28
28
block_map[it]=block_count;
29
29
30
+ if (!it->source_location .is_nil () &&
31
+ source_location_map.find (block_count)==source_location_map.end ())
32
+ source_location_map[block_count]=it->source_location ;
33
+
30
34
next_is_target=
31
35
it->is_goto () || it->is_return () ||
32
36
it->is_function_call () || it->is_assume ();
33
37
}
34
38
}
35
-
39
+
40
+ // map program locations to block numbers
36
41
typedef std::map<goto_programt::const_targett, unsigned > block_mapt;
37
42
block_mapt block_map;
38
43
44
+ // map block numbers to source code locations
45
+ typedef std::map<unsigned , source_locationt> source_location_mapt;
46
+ source_location_mapt source_location_map;
47
+
39
48
inline unsigned operator [](goto_programt::const_targett t)
40
49
{
41
50
return block_map[t];
@@ -134,12 +143,14 @@ void instrument_cover_goals(
134
143
{
135
144
std::string b=i2string (block_nr);
136
145
std::string id=id2string (i_it->function )+" #" +b;
137
- if (i_it->source_location .get_file ()!=" " )
146
+ source_locationt source_location=
147
+ basic_blocks.source_location_map [block_nr];
148
+
149
+ if (source_location.get_file ()!=" " )
138
150
{
139
151
std::string comment=
140
- " block " +i_it-> source_location .as_string ()+" " +i2string (i_it->location_number );
152
+ " block " +source_location.as_string ()+" " +i2string (i_it->location_number );
141
153
142
- source_locationt source_location=i_it->source_location ;
143
154
goto_program.insert_before_swap (i_it);
144
155
i_it->make_assertion (false_exprt ());
145
156
i_it->source_location =source_location;
0 commit comments