@@ -190,11 +190,21 @@ class SourceMappingRegion {
190
190
191
191
bool isBranch () const { return FalseCount.has_value (); }
192
192
193
+ bool isMCDCBranch () const {
194
+ const auto *BranchParams = std::get_if<mcdc::BranchParameters>(&MCDCParams);
195
+ assert (BranchParams == nullptr || BranchParams->ID >= 0 );
196
+ return (BranchParams != nullptr );
197
+ }
198
+
199
+ const auto &getMCDCBranchParams () const {
200
+ return mcdc::getParams<const mcdc::BranchParameters>(MCDCParams);
201
+ }
202
+
193
203
bool isMCDCDecision () const {
194
204
const auto *DecisionParams =
195
205
std::get_if<mcdc::DecisionParameters>(&MCDCParams);
196
- assert (! DecisionParams || DecisionParams->NumConditions > 0 );
197
- return DecisionParams;
206
+ assert (DecisionParams == nullptr || DecisionParams->NumConditions > 0 );
207
+ return ( DecisionParams != nullptr ) ;
198
208
}
199
209
200
210
const auto &getMCDCDecisionParams () const {
@@ -464,13 +474,19 @@ class CoverageMappingBuilder {
464
474
// Ignore regions from system headers unless collecting coverage from
465
475
// system headers is explicitly enabled.
466
476
if (!SystemHeadersCoverage &&
467
- SM.isInSystemHeader (SM.getSpellingLoc (LocStart)))
477
+ SM.isInSystemHeader (SM.getSpellingLoc (LocStart))) {
478
+ assert (!Region.isMCDCBranch () && !Region.isMCDCDecision () &&
479
+ " Don't suppress the condition in system headers" );
468
480
continue ;
481
+ }
469
482
470
483
auto CovFileID = getCoverageFileID (LocStart);
471
484
// Ignore regions that don't have a file, such as builtin macros.
472
- if (!CovFileID)
485
+ if (!CovFileID) {
486
+ assert (!Region.isMCDCBranch () && !Region.isMCDCDecision () &&
487
+ " Don't suppress the condition in non-file regions" );
473
488
continue ;
489
+ }
474
490
475
491
SourceLocation LocEnd = Region.getEndLoc ();
476
492
assert (SM.isWrittenInSameFile (LocStart, LocEnd) &&
@@ -480,8 +496,11 @@ class CoverageMappingBuilder {
480
496
// This not only suppresses redundant regions, but sometimes prevents
481
497
// creating regions with wrong counters if, for example, a statement's
482
498
// body ends at the end of a nested macro.
483
- if (Filter.count (std::make_pair (LocStart, LocEnd)))
499
+ if (Filter.count (std::make_pair (LocStart, LocEnd))) {
500
+ assert (!Region.isMCDCBranch () && !Region.isMCDCDecision () &&
501
+ " Don't suppress the condition" );
484
502
continue ;
503
+ }
485
504
486
505
// Find the spelling locations for the mapping region.
487
506
SpellingRegion SR{SM, LocStart, LocEnd};
0 commit comments