@@ -400,26 +400,23 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
400
400
// each node. When a terminal node (ID == 0) is reached, fill in the value in
401
401
// the truth table.
402
402
void buildTestVector (MCDCRecord::TestVector &TV, mcdc::ConditionID ID,
403
- int TVIdx, unsigned Index) {
404
- assert ((Index & (1 << ID)) == 0 );
405
-
403
+ int TVIdx) {
406
404
for (auto MCDCCond : {MCDCRecord::MCDC_False, MCDCRecord::MCDC_True}) {
407
405
static_assert (MCDCRecord::MCDC_False == 0 );
408
406
static_assert (MCDCRecord::MCDC_True == 1 );
409
- Index |= MCDCCond << ID;
410
- TV[ID] = MCDCCond;
407
+ TV.set (ID, MCDCCond);
411
408
auto NextID = NextIDs[ID][MCDCCond];
412
409
auto NextTVIdx = TVIdx + Indices[ID][MCDCCond];
413
410
assert (NextID == SavedNodes[ID].NextIDs [MCDCCond]);
414
411
if (NextID >= 0 ) {
415
- buildTestVector (TV, NextID, NextTVIdx, Index );
412
+ buildTestVector (TV, NextID, NextTVIdx);
416
413
continue ;
417
414
}
418
415
419
416
assert (TVIdx < SavedNodes[ID].Width );
420
417
assert (TVIdxs.insert (NextTVIdx).second && " Duplicate TVIdx" );
421
418
422
- if (!Bitmap[DecisionParams.BitmapIdx * CHAR_BIT + Index ])
419
+ if (!Bitmap[DecisionParams.BitmapIdx * CHAR_BIT + TV. getIndex () ])
423
420
continue ;
424
421
425
422
// Copy the completed test vector to the vector of testvectors.
@@ -429,7 +426,7 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
429
426
}
430
427
431
428
// Reset back to DontCare.
432
- TV[ID] = MCDCRecord::MCDC_DontCare;
429
+ TV. set (ID, MCDCRecord::MCDC_DontCare) ;
433
430
}
434
431
435
432
// / Walk the bits in the bitmap. A bit set to '1' indicates that the test
@@ -439,8 +436,8 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
439
436
// We start at the root node (ID == 0) with all values being DontCare.
440
437
// `TVIdx` starts with 0 and is in the traversal.
441
438
// `Index` encodes the bitmask of true values and is initially 0.
442
- MCDCRecord::TestVector TV (NumConditions, MCDCRecord::MCDC_DontCare );
443
- buildTestVector (TV, 0 , 0 , 0 );
439
+ MCDCRecord::TestVector TV (NumConditions);
440
+ buildTestVector (TV, 0 , 0 );
444
441
assert (TVIdxs.size () == unsigned (NumTestVectors) &&
445
442
" TVIdxs wasn't fulfilled" );
446
443
@@ -465,20 +462,12 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
465
462
for (unsigned J = 0 ; J < NumExecVectorsF; ++J) {
466
463
const auto &[B, BCond] = ExecVectors[J];
467
464
assert (BCond == MCDCRecord::MCDC_False);
468
- unsigned Flip = NumConditions, Idx;
469
- for (Idx = 0 ; Idx < NumConditions; ++Idx) {
470
- MCDCRecord::CondState ACond = A[Idx], BCond = B[Idx];
471
- if (ACond == BCond || ACond == MCDCRecord::MCDC_DontCare ||
472
- BCond == MCDCRecord::MCDC_DontCare)
473
- continue ;
474
- if (Flip != NumConditions)
475
- break ;
476
- Flip = Idx;
477
- }
478
465
// If the two vectors differ in exactly one condition, ignoring DontCare
479
466
// conditions, we have found an independence pair.
480
- if (Idx == NumConditions && Flip != NumConditions)
481
- IndependencePairs.insert ({Flip, std::make_pair (J + 1 , I + 1 )});
467
+ auto AB = A.getDifferences (B);
468
+ if (AB.count () == 1 )
469
+ IndependencePairs.insert (
470
+ {AB.find_first (), std::make_pair (J + 1 , I + 1 )});
482
471
}
483
472
}
484
473
}
0 commit comments