summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-09-09 05:32:18 +0000
committerJustin Bogner <mail@justinbogner.com>2014-09-09 05:32:18 +0000
commite53be0662adacb2a98b17d2375d781d0ce819805 (patch)
treeb0224c95482f5e145438c434f8b9d4cb47b1c6b3 /llvm/tools/llvm-cov/SourceCoverageDataManager.cpp
parent8e8aa3ff90448eea2a0ad69368062f87c7fd4058 (diff)
downloadbcm5719-llvm-e53be0662adacb2a98b17d2375d781d0ce819805.tar.gz
bcm5719-llvm-e53be0662adacb2a98b17d2375d781d0ce819805.zip
llvm-cov: Combine two types that were nearly identical (NFC)
llvm-cov had a SourceRange type that was nearly identical to a CountedRegion except that it shaved off a couple of fields. There aren't likely to be enough of these for the minor memory savings to be worth the extra complexity here. llvm-svn: 217417
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageDataManager.cpp')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageDataManager.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp b/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp
index 4c4d7c038d6..f64162822ab 100644
--- a/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp
@@ -18,31 +18,22 @@ using namespace llvm;
using namespace coverage;
void SourceCoverageDataManager::insert(const CountedRegion &CR) {
- SourceRange Range(CR.LineStart, CR.ColumnStart, CR.LineEnd, CR.ColumnEnd);
- if (CR.Kind == CounterMappingRegion::SkippedRegion) {
- SkippedRegions.push_back(Range);
- return;
- }
- Regions.push_back(std::make_pair(Range, CR.ExecutionCount));
+ Regions.push_back(CR);
+ Uniqued = false;
}
-ArrayRef<std::pair<SourceCoverageDataManager::SourceRange, uint64_t>>
-SourceCoverageDataManager::getSourceRegions() {
+ArrayRef<CountedRegion> SourceCoverageDataManager::getSourceRegions() {
if (Uniqued || Regions.size() <= 1)
return Regions;
// Sort.
- std::sort(Regions.begin(), Regions.end(),
- [](const std::pair<SourceRange, uint64_t> &LHS,
- const std::pair<SourceRange, uint64_t> &RHS) {
- return LHS.first < RHS.first;
- });
+ std::sort(Regions.begin(), Regions.end());
// Merge duplicate source ranges and sum their execution counts.
auto Prev = Regions.begin();
for (auto I = Prev + 1, E = Regions.end(); I != E; ++I) {
- if (I->first == Prev->first) {
- Prev->second += I->second;
+ if (I->coversSameSource(*Prev)) {
+ Prev->ExecutionCount += I->ExecutionCount;
continue;
}
++Prev;
OpenPOWER on IntegriCloud