22 if(instruction->incoming_edges.size() != 1)
26 if(in_t->is_goto() && !in_t->is_backwards_goto() && in_t->guard.is_true())
34 bool next_is_target =
true;
35 std::size_t current_block = 0;
40 if(next_is_target || it->is_target())
44 current_block = *block_number;
56 current_block <
block_infos.size(),
"current block number out of range");
62 const irep_idt &line = it->source_location.get_line();
68 !it->source_location.is_nil() &&
69 !it->source_location.get_file().empty() &&
70 !it->source_location.get_line().empty() &&
71 block_info.source_location.is_nil())
73 block_info.representative_inst = it;
74 block_info.source_location = it->source_location;
80 it->is_goto() || it->is_function_call() || it->is_assume();
82 it->is_goto() || it->is_function_call();
116 std::set<std::size_t> blocks_seen;
119 const std::size_t block_nr =
block_of(it);
123 blocks_seen.insert(block_nr).second &&
126 msg.
warning() <<
"Ignoring block " << (block_nr + 1) <<
" location " 128 <<
" (bytecode-index already instrumented)" 135 msg.
warning() <<
"Ignoring block " << (block_nr + 1) <<
" location " 136 << it->location_number <<
" " << it->function
147 out << block_pair.first->source_location <<
" -> " << block_pair.second
156 const auto &cover_set = block_info.
lines;
157 INVARIANT(!cover_set.empty(),
"covered lines set must not be empty");
158 std::vector<unsigned> line_list(cover_set.begin(), cover_set.end());
169 const auto &location = it->source_location;
170 const auto &bytecode_index = location.get_java_bytecode_index();
175 block_locations.back().set_basic_block_covered_lines(location.get_line());
183 const auto &bytecode_index = t->source_location.get_java_bytecode_index();
const source_locationt & source_location_of(std::size_t block_number) const override
std::unordered_set< std::size_t > lines
the set of lines belonging to this block
optionalt< goto_programt::const_targett > instruction_of(std::size_t block_nr) const override
const std::string & id2string(const irep_idt &d)
cover_basic_blockst(const goto_programt &_goto_program)
static const source_locationt & nil()
unsigned unsafe_string2unsigned(const std::string &str, int base)
optionalt< goto_programt::const_targett > representative_inst
the program location to instrument for this block
Basic blocks detection for Coverage Instrumentation.
const source_locationt & source_location_of(std::size_t block_nr) const override
mstreamt & warning() const
std::vector< goto_programt::const_targett > block_infos
instructionst::iterator targett
source_locationt source_location
nonstd::optional< T > optionalt
instructionst instructions
The list of instructions in the goto program.
instructionst::const_iterator const_targett
std::unordered_map< irep_idt, std::size_t > index_to_block
#define PRECONDITION(CONDITION)
source_locationt source_location
the source location representative for this block (we need a separate copy of source locations becaus...
static optionalt< std::size_t > continuation_of_block(const goto_programt::const_targett &instruction, block_mapt &block_map)
If this block is a continuation of a previous block through unconditional forward gotos,...
Class that provides messages with a built-in verbosity 'level'.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
optionalt< goto_programt::const_targett > instruction_of(std::size_t block_number) const override
A generic container class for the GOTO intermediate representation of one function.
std::vector< source_locationt > block_locations
void output(std::ostream &out) const override
Outputs the list of blocks.
void report_block_anomalies(const goto_programt &goto_program, message_handlert &message_handler) override
Output warnings about ignored blocks.
cover_basic_blocks_javat(const goto_programt &_goto_program)
void output(std::ostream &out) const override
Outputs the list of blocks.
block_mapt block_map
map program locations to block numbers
std::size_t block_of(goto_programt::const_targett t) const override
static void update_covered_lines(block_infot &block_info)
create list of covered lines as CSV string and set as property of source location of basic block,...
std::map< goto_programt::const_targett, std::size_t > block_mapt
#define forall_goto_program_instructions(it, program)
std::size_t block_of(goto_programt::const_targett t) const override
std::vector< block_infot > block_infos
map block numbers to block information
void set_basic_block_covered_lines(const irep_idt &covered_lines)