@@ -95,9 +95,6 @@ void CoverageSourceInfo::updateNextTokLoc(SourceLocation Loc) {
95
95
}
96
96
97
97
namespace {
98
- using MCDCConditionID = CounterMappingRegion::MCDCConditionID;
99
- using MCDCParameters = CounterMappingRegion::MCDCParameters;
100
-
101
98
// / A region of source code that can be mapped to a counter.
102
99
class SourceMappingRegion {
103
100
// / Primary Counter that is also used for Branch Regions for "True" branches.
@@ -107,7 +104,7 @@ class SourceMappingRegion {
107
104
std::optional<Counter> FalseCount;
108
105
109
106
// / Parameters used for Modified Condition/Decision Coverage
110
- MCDCParameters MCDCParams;
107
+ mcdc::Parameters MCDCParams;
111
108
112
109
// / The region's starting location.
113
110
std::optional<SourceLocation> LocStart;
@@ -131,15 +128,15 @@ class SourceMappingRegion {
131
128
SkippedRegion (false ) {}
132
129
133
130
SourceMappingRegion (Counter Count, std::optional<Counter> FalseCount,
134
- MCDCParameters MCDCParams,
131
+ mcdc::Parameters MCDCParams,
135
132
std::optional<SourceLocation> LocStart,
136
133
std::optional<SourceLocation> LocEnd,
137
134
bool GapRegion = false )
138
135
: Count(Count), FalseCount(FalseCount), MCDCParams(MCDCParams),
139
136
LocStart(LocStart), LocEnd(LocEnd), GapRegion(GapRegion),
140
137
SkippedRegion(false ) {}
141
138
142
- SourceMappingRegion (MCDCParameters MCDCParams,
139
+ SourceMappingRegion (mcdc::Parameters MCDCParams,
143
140
std::optional<SourceLocation> LocStart,
144
141
std::optional<SourceLocation> LocEnd)
145
142
: MCDCParams(MCDCParams), LocStart(LocStart), LocEnd(LocEnd),
@@ -187,7 +184,7 @@ class SourceMappingRegion {
187
184
188
185
bool isMCDCDecision () const { return MCDCParams.NumConditions != 0 ; }
189
186
190
- const MCDCParameters &getMCDCParams () const { return MCDCParams; }
187
+ const mcdc::Parameters &getMCDCParams () const { return MCDCParams; }
191
188
};
192
189
193
190
// / Spelling locations for the start and end of a source region.
@@ -587,8 +584,8 @@ struct EmptyCoverageMappingBuilder : public CoverageMappingBuilder {
587
584
struct MCDCCoverageBuilder {
588
585
589
586
struct DecisionIDPair {
590
- MCDCConditionID TrueID = 0 ;
591
- MCDCConditionID FalseID = 0 ;
587
+ mcdc::ConditionID TrueID = 0 ;
588
+ mcdc::ConditionID FalseID = 0 ;
592
589
};
593
590
594
591
// / The AST walk recursively visits nested logical-AND or logical-OR binary
@@ -682,9 +679,9 @@ struct MCDCCoverageBuilder {
682
679
CodeGenModule &CGM;
683
680
684
681
llvm::SmallVector<DecisionIDPair> DecisionStack;
685
- llvm::DenseMap<const Stmt *, MCDCConditionID > &CondIDs;
682
+ llvm::DenseMap<const Stmt *, mcdc::ConditionID > &CondIDs;
686
683
llvm::DenseMap<const Stmt *, unsigned > &MCDCBitmapMap;
687
- MCDCConditionID NextID = 1 ;
684
+ mcdc::ConditionID NextID = 1 ;
688
685
bool NotMapped = false ;
689
686
690
687
// / Represent a sentinel value of [0,0] for the bottom of DecisionStack.
@@ -696,9 +693,10 @@ struct MCDCCoverageBuilder {
696
693
}
697
694
698
695
public:
699
- MCDCCoverageBuilder (CodeGenModule &CGM,
700
- llvm::DenseMap<const Stmt *, MCDCConditionID> &CondIDMap,
701
- llvm::DenseMap<const Stmt *, unsigned > &MCDCBitmapMap)
696
+ MCDCCoverageBuilder (
697
+ CodeGenModule &CGM,
698
+ llvm::DenseMap<const Stmt *, mcdc::ConditionID> &CondIDMap,
699
+ llvm::DenseMap<const Stmt *, unsigned > &MCDCBitmapMap)
702
700
: CGM(CGM), DecisionStack(1 , DecisionStackSentinel), CondIDs(CondIDMap),
703
701
MCDCBitmapMap (MCDCBitmapMap) {}
704
702
@@ -713,12 +711,12 @@ struct MCDCCoverageBuilder {
713
711
bool isBuilding () const { return (NextID > 1 ); }
714
712
715
713
// / Set the given condition's ID.
716
- void setCondID (const Expr *Cond, MCDCConditionID ID) {
714
+ void setCondID (const Expr *Cond, mcdc::ConditionID ID) {
717
715
CondIDs[CodeGenFunction::stripCond (Cond)] = ID;
718
716
}
719
717
720
718
// / Return the ID of a given condition.
721
- MCDCConditionID getCondID (const Expr *Cond) const {
719
+ mcdc::ConditionID getCondID (const Expr *Cond) const {
722
720
auto I = CondIDs.find (CodeGenFunction::stripCond (Cond));
723
721
if (I == CondIDs.end ())
724
722
return 0 ;
@@ -755,7 +753,7 @@ struct MCDCCoverageBuilder {
755
753
setCondID (E->getLHS (), NextID++);
756
754
757
755
// Assign a ID+1 for the RHS.
758
- MCDCConditionID RHSid = NextID++;
756
+ mcdc::ConditionID RHSid = NextID++;
759
757
setCondID (E->getRHS (), RHSid);
760
758
761
759
// Push the LHS decision IDs onto the DecisionStack.
@@ -865,8 +863,8 @@ struct CounterCoverageMappingBuilder
865
863
std::optional<SourceLocation> StartLoc = std::nullopt,
866
864
std::optional<SourceLocation> EndLoc = std::nullopt,
867
865
std::optional<Counter> FalseCount = std::nullopt,
868
- MCDCConditionID ID = 0 , MCDCConditionID TrueID = 0 ,
869
- MCDCConditionID FalseID = 0 ) {
866
+ mcdc::ConditionID ID = 0 , mcdc::ConditionID TrueID = 0 ,
867
+ mcdc::ConditionID FalseID = 0 ) {
870
868
871
869
if (StartLoc && !FalseCount) {
872
870
MostRecentLocation = *StartLoc;
@@ -886,7 +884,7 @@ struct CounterCoverageMappingBuilder
886
884
if (EndLoc && EndLoc->isInvalid ())
887
885
EndLoc = std::nullopt;
888
886
RegionStack.emplace_back (Count, FalseCount,
889
- MCDCParameters {0 , 0 , ID, TrueID, FalseID},
887
+ mcdc::Parameters {0 , 0 , ID, TrueID, FalseID},
890
888
StartLoc, EndLoc);
891
889
892
890
return RegionStack.size () - 1 ;
@@ -896,7 +894,7 @@ struct CounterCoverageMappingBuilder
896
894
std::optional<SourceLocation> StartLoc = std::nullopt,
897
895
std::optional<SourceLocation> EndLoc = std::nullopt) {
898
896
899
- RegionStack.emplace_back (MCDCParameters {BitmapIdx, Conditions}, StartLoc,
897
+ RegionStack.emplace_back (mcdc::Parameters {BitmapIdx, Conditions}, StartLoc,
900
898
EndLoc);
901
899
902
900
return RegionStack.size () - 1 ;
@@ -1042,9 +1040,9 @@ struct CounterCoverageMappingBuilder
1042
1040
// function's SourceRegions) because it doesn't apply to any other source
1043
1041
// code other than the Condition.
1044
1042
if (CodeGenFunction::isInstrumentedCondition (C)) {
1045
- MCDCConditionID ID = MCDCBuilder.getCondID (C);
1046
- MCDCConditionID TrueID = IDPair.TrueID ;
1047
- MCDCConditionID FalseID = IDPair.FalseID ;
1043
+ mcdc::ConditionID ID = MCDCBuilder.getCondID (C);
1044
+ mcdc::ConditionID TrueID = IDPair.TrueID ;
1045
+ mcdc::ConditionID FalseID = IDPair.FalseID ;
1048
1046
1049
1047
// If a condition can fold to true or false, the corresponding branch
1050
1048
// will be removed. Create a region with both counters hard-coded to
@@ -1151,9 +1149,9 @@ struct CounterCoverageMappingBuilder
1151
1149
if (I.isBranch ())
1152
1150
SourceRegions.emplace_back (
1153
1151
I.getCounter (), I.getFalseCounter (),
1154
- MCDCParameters {0 , 0 , I.getMCDCParams ().ID ,
1155
- I.getMCDCParams ().TrueID ,
1156
- I.getMCDCParams ().FalseID },
1152
+ mcdc::Parameters {0 , 0 , I.getMCDCParams ().ID ,
1153
+ I.getMCDCParams ().TrueID ,
1154
+ I.getMCDCParams ().FalseID },
1157
1155
Loc, getEndOfFileOrMacro (Loc), I.isBranch ());
1158
1156
else
1159
1157
SourceRegions.emplace_back (I.getCounter (), Loc,
@@ -1338,7 +1336,7 @@ struct CounterCoverageMappingBuilder
1338
1336
CoverageMappingModuleGen &CVM,
1339
1337
llvm::DenseMap<const Stmt *, unsigned > &CounterMap,
1340
1338
llvm::DenseMap<const Stmt *, unsigned > &MCDCBitmapMap,
1341
- llvm::DenseMap<const Stmt *, MCDCConditionID > &CondIDMap,
1339
+ llvm::DenseMap<const Stmt *, mcdc::ConditionID > &CondIDMap,
1342
1340
SourceManager &SM, const LangOptions &LangOpts)
1343
1341
: CoverageMappingBuilder(CVM, SM, LangOpts), CounterMap(CounterMap),
1344
1342
MCDCBitmapMap (MCDCBitmapMap),
0 commit comments