Skip to content

Commit 3339de3

Browse files
kroeningtautschnig
authored andcommitted
label_properties now generates a source location if there is none
A source_locationt with id() nil signals that the source location is not given; an empty string signals that the source location is given. Goto instructions without source location are perfectly valid, but we need a source location to carry the property id. This fixes label_properties to create a source location with the right function name if none is given.
1 parent d546c4b commit 3339de3

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ void jbmc_parse_optionst::process_goto_function(
725725
if(using_symex_driven_loading)
726726
{
727727
// label the assertions
728-
label_properties(goto_function.body);
728+
label_properties(function.get_function_id(), goto_function.body);
729729

730730
goto_function.body.update();
731731
function.compute_location_numbers();

src/goto-programs/set_properties.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void label_properties(goto_modelt &goto_model)
4848
}
4949

5050
void label_properties(
51+
const irep_idt function_identifier,
5152
goto_programt &goto_program,
5253
std::map<irep_idt, std::size_t> &property_counters)
5354
{
@@ -59,6 +60,13 @@ void label_properties(
5960
if(!it->is_assert())
6061
continue;
6162

63+
// No source location? Create one.
64+
if(it->source_location().is_nil())
65+
{
66+
it->source_location_nonconst() = source_locationt{};
67+
it->source_location_nonconst().set_function(function_identifier);
68+
}
69+
6270
irep_idt function = it->source_location().get_function();
6371

6472
std::string prefix=id2string(function);
@@ -89,10 +97,10 @@ void label_properties(
8997
}
9098
}
9199

92-
void label_properties(goto_programt &goto_program)
100+
void label_properties(irep_idt function_identifier, goto_programt &goto_program)
93101
{
94102
std::map<irep_idt, std::size_t> property_counters;
95-
label_properties(goto_program, property_counters);
103+
label_properties(function_identifier, goto_program, property_counters);
96104
}
97105

98106
void set_properties(
@@ -127,5 +135,5 @@ void label_properties(goto_functionst &goto_functions)
127135
it=goto_functions.function_map.begin();
128136
it!=goto_functions.function_map.end();
129137
it++)
130-
label_properties(it->second.body, property_counters);
138+
label_properties(it->first, it->second.body, property_counters);
131139
}

src/goto-programs/set_properties.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H
1313
#define CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H
1414

15+
#include <util/irep.h>
16+
1517
#include <list>
16-
#include <string>
1718

1819
class goto_functionst;
1920
class goto_modelt;
@@ -28,7 +29,7 @@ void set_properties(
2829
const std::list<std::string> &properties);
2930

3031
void label_properties(goto_functionst &);
31-
void label_properties(goto_programt &);
32+
void label_properties(irep_idt function_identifier, goto_programt &);
3233
void label_properties(goto_modelt &);
3334

3435
#endif // CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H

0 commit comments

Comments
 (0)