Skip to content

Commit e469a3e

Browse files
committed
[coverage] keep relative order of mcdc branch and decision mapping regions
1 parent 6f1013a commit e469a3e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,15 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
165165
const CounterMappingRegion &RHS) {
166166
if (LHS.FileID != RHS.FileID)
167167
return LHS.FileID < RHS.FileID;
168-
if (LHS.startLoc() != RHS.startLoc())
168+
169+
auto ignoreLocationComparison = [](const CounterMappingRegion &LHS,
170+
const CounterMappingRegion &RHS) {
171+
return (LHS.Kind == CounterMappingRegion::MCDCBranchRegion ||
172+
LHS.Kind == CounterMappingRegion::MCDCDecisionRegion) &&
173+
LHS.Kind == RHS.Kind;
174+
};
175+
176+
if (!ignoreLocationComparison(LHS, RHS) && LHS.startLoc() != RHS.startLoc())
169177
return LHS.startLoc() < RHS.startLoc();
170178

171179
// Put `Decision` before `Expansion`.

0 commit comments

Comments
 (0)