return std::pair<unsigned, unsigned>(LineEnd, ColumnEnd);
}
- bool operator<(const CounterMappingRegion &Other) const {
- if (FileID != Other.FileID)
- return FileID < Other.FileID;
- return startLoc() < Other.startLoc();
- }
-
bool contains(const CounterMappingRegion &Other) const {
if (FileID != Other.FileID)
return false;
void CoverageMappingWriter::write(raw_ostream &OS) {
// Sort the regions in an ascending order by the file id and the starting
- // location.
- std::stable_sort(MappingRegions.begin(), MappingRegions.end());
+ // location. Sort by region kinds to ensure stable order for tests.
+ std::stable_sort(
+ MappingRegions.begin(), MappingRegions.end(),
+ [](const CounterMappingRegion &LHS, const CounterMappingRegion &RHS) {
+ if (LHS.FileID != RHS.FileID)
+ return LHS.FileID < RHS.FileID;
+ if (LHS.startLoc() != RHS.startLoc())
+ return LHS.startLoc() < RHS.startLoc();
+ return LHS.Kind < RHS.Kind;
+ });
// Write out the fileid -> filename mapping.
encodeULEB128(VirtualFileMapping.size(), OS);