@@ -596,56 +596,49 @@ struct DecisionRow {
596
596
: DecisionRegion(&Decision), DecisionStartLoc(Decision.startLoc()),
597
597
DecisionEndLoc (Decision.endLoc()) {}
598
598
599
- bool insert (const CounterMappingRegion &Branch) {
600
- auto ID = Branch.MCDCParams .ID ;
601
- if (ID == 1 )
602
- Branches.insert (Branches.begin (), &Branch);
603
- else
604
- Branches.push_back (&Branch);
605
- IDs.insert (ID);
606
- return (Branches.size () == DecisionRegion->MCDCParams .NumConditions );
599
+ bool inDecisionRegion (const CounterMappingRegion &R) {
600
+ return (R.FileID == DecisionRegion->FileID &&
601
+ R.startLoc () >= DecisionStartLoc && R.endLoc () <= DecisionEndLoc);
602
+ }
603
+
604
+ bool inExpansions (const CounterMappingRegion &R) {
605
+ return any_of (Expansions, [&](const auto &Expansion) {
606
+ return (Expansion->ExpandedFileID == R.FileID );
607
+ });
607
608
}
608
609
609
610
enum class UpdateResult {
610
611
NotFound = 0 ,
611
612
Updated,
612
- Committed ,
613
+ Completed ,
613
614
};
614
615
615
616
UpdateResult updateBranch (const CounterMappingRegion &Branch) {
616
- if (IDs.contains (Branch.MCDCParams .ID ))
617
- return UpdateResult::NotFound;
617
+ auto ID = Branch.MCDCParams .ID ;
618
618
619
- if (Branch.FileID == DecisionRegion->FileID &&
620
- Branch.startLoc () >= DecisionStartLoc &&
621
- Branch.endLoc () <= DecisionEndLoc)
622
- return (insert (Branch) ? UpdateResult::Committed : UpdateResult::Updated);
619
+ if (!IDs.contains (ID) &&
620
+ (inDecisionRegion (Branch) || inExpansions (Branch))) {
621
+ assert (Branches.size () < DecisionRegion->MCDCParams .NumConditions );
623
622
624
- for (const auto *R : Expansions) {
625
- if (Branch.FileID == R->ExpandedFileID )
626
- return (insert (Branch) ? UpdateResult::Committed
627
- : UpdateResult::Updated);
628
- }
623
+ if (ID == 1 )
624
+ Branches.insert (Branches.begin (), &Branch);
625
+ else
626
+ Branches.push_back (&Branch);
629
627
630
- return UpdateResult::NotFound;
628
+ IDs.insert (ID);
629
+ return (Branches.size () == DecisionRegion->MCDCParams .NumConditions
630
+ ? UpdateResult::Completed
631
+ : UpdateResult::Updated);
632
+ } else
633
+ return UpdateResult::NotFound;
631
634
}
632
635
633
636
bool updateExpansion (const CounterMappingRegion &Expansion) {
634
- if (Expansion.FileID == DecisionRegion->FileID &&
635
- Expansion.startLoc () >= DecisionStartLoc &&
636
- Expansion.endLoc () <= DecisionEndLoc) {
637
+ if (inDecisionRegion (Expansion) || inExpansions (Expansion)) {
637
638
Expansions.push_back (&Expansion);
638
639
return true ;
639
- }
640
-
641
- for (const auto *R : Expansions) {
642
- if (Expansion.FileID == R->ExpandedFileID ) {
643
- Expansions.push_back (&Expansion);
644
- return true ;
645
- }
646
- }
647
-
648
- return false ;
640
+ } else
641
+ return false ;
649
642
}
650
643
};
651
644
@@ -749,7 +742,7 @@ Error CoverageMapping::loadFunctionRecord(
749
742
continue ;
750
743
case DecisionRow::UpdateResult::Updated:
751
744
goto branch_found;
752
- case DecisionRow::UpdateResult::Committed :
745
+ case DecisionRow::UpdateResult::Completed :
753
746
// Evaluating the test vector bitmap for the decision region entails
754
747
// calculating precisely what bits are pertinent to this region alone.
755
748
// This is calculated based on the recorded offset into the global
0 commit comments