@@ -36,18 +36,31 @@ class cover_instrumenter_baset
3636 {
3737 }
3838
39+ // / The type of function used to make goto_program assertions.
40+ using assertion_factoryt = std::function<
41+ goto_programt::instructiont (const exprt &, const source_locationt &)>;
42+ static_assert (
43+ std::is_same<
44+ assertion_factoryt,
45+ std::function<decltype (goto_programt::make_assertion)>>::value,
46+ "`assertion_factoryt` is expected to have the same type as "
47+ "`goto_programt::make_assertion`.");
48+
3949 // / Instruments a goto program
4050 // / \param function_id: name of \p goto_program
4151 // / \param goto_program: a goto program
4252 // / \param basic_blocks: detected basic blocks
43- virtual void operator ()(
53+ // / \param make_assertion: A function which makes goto program assertions.
54+ // / This parameter may be used to customise the expressions asserted.
55+ void operator ()(
4456 const irep_idt &function_id,
4557 goto_programt &goto_program,
46- const cover_blocks_baset &basic_blocks) const
58+ const cover_blocks_baset &basic_blocks,
59+ const assertion_factoryt &make_assertion) const
4760 {
4861 Forall_goto_program_instructions (i_it, goto_program)
4962 {
50- instrument (function_id, goto_program, i_it, basic_blocks);
63+ instrument (function_id, goto_program, i_it, basic_blocks, make_assertion );
5164 }
5265 }
5366
@@ -63,7 +76,8 @@ class cover_instrumenter_baset
6376 const irep_idt &function_id,
6477 goto_programt &,
6578 goto_programt::targett &,
66- const cover_blocks_baset &) const = 0;
79+ const cover_blocks_baset &,
80+ const assertion_factoryt &) const = 0;
6781
6882 void initialize_source_location (
6983 goto_programt::targett t,
@@ -96,13 +110,16 @@ class cover_instrumenterst
96110 // / \param function_id: name of \p goto_program
97111 // / \param goto_program: a goto program
98112 // / \param basic_blocks: detected basic blocks of the goto program
113+ // / \param make_assertion: A function which makes goto program assertions.
114+ // / This parameter may be used to customise the expressions asserted.
99115 void operator ()(
100116 const irep_idt &function_id,
101117 goto_programt &goto_program,
102- const cover_blocks_baset &basic_blocks) const
118+ const cover_blocks_baset &basic_blocks,
119+ const cover_instrumenter_baset::assertion_factoryt &make_assertion) const
103120 {
104121 for (const auto &instrumenter : instrumenters)
105- (*instrumenter)(function_id, goto_program, basic_blocks);
122+ (*instrumenter)(function_id, goto_program, basic_blocks, make_assertion );
106123 }
107124
108125private:
@@ -125,7 +142,8 @@ class cover_location_instrumentert : public cover_instrumenter_baset
125142 const irep_idt &function_id,
126143 goto_programt &,
127144 goto_programt::targett &,
128- const cover_blocks_baset &) const override ;
145+ const cover_blocks_baset &,
146+ const assertion_factoryt &) const override ;
129147};
130148
131149// / Branch coverage instrumenter
@@ -144,7 +162,8 @@ class cover_branch_instrumentert : public cover_instrumenter_baset
144162 const irep_idt &function_id,
145163 goto_programt &,
146164 goto_programt::targett &,
147- const cover_blocks_baset &) const override ;
165+ const cover_blocks_baset &,
166+ const assertion_factoryt &) const override ;
148167};
149168
150169// / Condition coverage instrumenter
@@ -163,7 +182,8 @@ class cover_condition_instrumentert : public cover_instrumenter_baset
163182 const irep_idt &function_id,
164183 goto_programt &,
165184 goto_programt::targett &,
166- const cover_blocks_baset &) const override ;
185+ const cover_blocks_baset &,
186+ const assertion_factoryt &) const override ;
167187};
168188
169189// / Decision coverage instrumenter
@@ -182,7 +202,8 @@ class cover_decision_instrumentert : public cover_instrumenter_baset
182202 const irep_idt &function_id,
183203 goto_programt &,
184204 goto_programt::targett &,
185- const cover_blocks_baset &) const override ;
205+ const cover_blocks_baset &,
206+ const assertion_factoryt &) const override ;
186207};
187208
188209// / MC/DC coverage instrumenter
@@ -201,7 +222,8 @@ class cover_mcdc_instrumentert : public cover_instrumenter_baset
201222 const irep_idt &function_id,
202223 goto_programt &,
203224 goto_programt::targett &,
204- const cover_blocks_baset &) const override ;
225+ const cover_blocks_baset &,
226+ const assertion_factoryt &) const override ;
205227};
206228
207229// / Path coverage instrumenter
@@ -220,7 +242,8 @@ class cover_path_instrumentert : public cover_instrumenter_baset
220242 const irep_idt &function_id,
221243 goto_programt &,
222244 goto_programt::targett &,
223- const cover_blocks_baset &) const override ;
245+ const cover_blocks_baset &,
246+ const assertion_factoryt &) const override ;
224247};
225248
226249// / Assertion coverage instrumenter
@@ -239,7 +262,8 @@ class cover_assertion_instrumentert : public cover_instrumenter_baset
239262 const irep_idt &function_id,
240263 goto_programt &,
241264 goto_programt::targett &,
242- const cover_blocks_baset &) const override ;
265+ const cover_blocks_baset &,
266+ const assertion_factoryt &) const override ;
243267};
244268
245269// / __CPROVER_cover coverage instrumenter
@@ -258,11 +282,13 @@ class cover_cover_instrumentert : public cover_instrumenter_baset
258282 const irep_idt &function_id,
259283 goto_programt &,
260284 goto_programt::targett &,
261- const cover_blocks_baset &) const override ;
285+ const cover_blocks_baset &,
286+ const assertion_factoryt &) const override ;
262287};
263288
264289void cover_instrument_end_of_function (
265290 const irep_idt &function_id,
266- goto_programt &goto_program);
291+ goto_programt &goto_program,
292+ const cover_instrumenter_baset::assertion_factoryt &);
267293
268294#endif // CPROVER_GOTO_INSTRUMENT_COVER_INSTRUMENT_H
0 commit comments