summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-09-08 18:44:47 +0000
committerVedant Kumar <vsk@apple.com>2017-09-08 18:44:47 +0000
commitbae8397006fcb479bc9bcfe84e826bacbfbe7891 (patch)
tree0c0ce2fffaaec799f50bf914d6f74ac9652b37af /llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
parent933b37f99f4f6f2ca3ab0d268caafc33c50bee84 (diff)
downloadbcm5719-llvm-bae8397006fcb479bc9bcfe84e826bacbfbe7891.tar.gz
bcm5719-llvm-bae8397006fcb479bc9bcfe84e826bacbfbe7891.zip
[Coverage] Report errors when reading malformed source regions
Each source region has a start and end location. Report an error when the end location does not precede the begin location. The old lineExecutionCounts.covmapping test actually had a buggy source region in it. This commit introduces a regenerated copy of the coverage and moves the old copy to malformedRegions.covmapping, for a test. Differential Revision: https://reviews.llvm.org/D37387 llvm-svn: 312814
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
index 6fe93530da2..4a1ce16c486 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -116,6 +116,13 @@ static void writeCounter(ArrayRef<CounterExpression> Expressions, Counter C,
}
void CoverageMappingWriter::write(raw_ostream &OS) {
+ // Check that we don't have any bogus regions.
+ assert(all_of(MappingRegions,
+ [](const CounterMappingRegion &CMR) {
+ return CMR.startLoc() <= CMR.endLoc();
+ }) &&
+ "Source region does not begin before it ends");
+
// Sort the regions in an ascending order by the file id and the starting
// location. Sort by region kinds to ensure stable order for tests.
std::stable_sort(
OpenPOWER on IntegriCloud