Skip to content

Commit 18c4d53

Browse files
committed
Do not directly handle an atomic condition within "collect_mcdc_controlling_rec".
1 parent a0d01d0 commit 18c4d53

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

regression/cbmc-cover/mcdc6/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ main.c
33
--cover mcdc
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[main.coverage.1\] file main.c line 4 function main MC/DC independence condition `!(x < (unsigned int)3).*: SATISFIED$
7-
^\[main.coverage.2\] file main.c line 4 function main MC/DC independence condition `x < (unsigned int)3.*: SATISFIED$
6+
^\[main.coverage.1\] file main.c line 4 function main decision/condition `x < (unsigned int)3.* false: SATISFIED$
7+
^\[main.coverage.2\] file main.c line 4 function main decision/condition `x < (unsigned int)3.* true: SATISFIED$
88
^\*\* .* of .* covered (100.0%)$
99
^\*\* Used 2 iterations$
1010
--

src/goto-instrument/cover.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,28 @@ void collect_mcdc_controlling_rec(
314314
else if(src.id()==ID_not)
315315
{
316316
exprt e=to_not_expr(src).op();
317-
collect_mcdc_controlling_rec(e, conditions, result);
318-
}
319-
else if(is_condition(src))
320-
{
321-
exprt e=src;
322-
std::vector<exprt> new_conditions1=conditions;
323-
new_conditions1.push_back(e);
324-
result.insert(conjunction(new_conditions1));
325-
326-
//e.make_not();
327-
std::vector<exprt> new_conditions2=conditions;
328-
new_conditions2.push_back(not_exprt(e));
329-
result.insert(conjunction(new_conditions2));
317+
if(not is_condition(e))
318+
collect_mcdc_controlling_rec(e, conditions, result);
319+
else
320+
{
321+
// to store a copy of ''src''
322+
std::vector<exprt> new_conditions1=conditions;
323+
new_conditions1.push_back(src);
324+
result.insert(conjunction(new_conditions1));
325+
326+
// to store a copy of its negation, i.e., ''e''
327+
std::vector<exprt> new_conditions2=conditions;
328+
new_conditions2.push_back(e);
329+
result.insert(conjunction(new_conditions2));
330+
}
330331
}
331332
else
332333
{
333-
throw "Unexpected exprt for MC/DC coverage";
334+
/**
335+
* It may happen that ''is_condition(src)'' is valid,
336+
* but we ignore this case here as it can be handled
337+
* by the routine decision/condition detection.
338+
**/
334339
}
335340
}
336341

0 commit comments

Comments
 (0)