summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/SourceCoverageDataManager.h
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-09-17 18:23:47 +0000
committerJustin Bogner <mail@justinbogner.com>2014-09-17 18:23:47 +0000
commitfe357c003f3a7c23aef0176d18eb22f0c5b0cd70 (patch)
tree91356d6e1b929f80d7229f9035a0421b2f0a0750 /llvm/tools/llvm-cov/SourceCoverageDataManager.h
parent2c8ed4b84fa01115deff4c5fc1d3b76924c354be (diff)
downloadbcm5719-llvm-fe357c003f3a7c23aef0176d18eb22f0c5b0cd70.tar.gz
bcm5719-llvm-fe357c003f3a7c23aef0176d18eb22f0c5b0cd70.zip
llvm-cov: Rework the API for getting the coverage of a file (NFC)
This encapsulates how we handle the coverage regions of a file or function. In the old model, the user had to deal with nested regions, so they needed to maintain their own auxiliary data structures to get any useful information out of this. The new API provides a sequence of non-overlapping coverage segments, which makes it possible to render coverage information in a single pass and avoids a fair amount of extra work. llvm-svn: 217975
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageDataManager.h')
-rw-r--r--llvm/tools/llvm-cov/SourceCoverageDataManager.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cov/SourceCoverageDataManager.h b/llvm/tools/llvm-cov/SourceCoverageDataManager.h
index abeca192e64..eec175222b4 100644
--- a/llvm/tools/llvm-cov/SourceCoverageDataManager.h
+++ b/llvm/tools/llvm-cov/SourceCoverageDataManager.h
@@ -19,19 +19,33 @@
namespace llvm {
+struct CoverageSegment {
+ unsigned Line;
+ unsigned Col;
+ bool IsRegionEntry;
+ uint64_t Count;
+ bool HasCount;
+
+ CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry)
+ : Line(Line), Col(Col), IsRegionEntry(IsRegionEntry),
+ Count(0), HasCount(false) {}
+ void setCount(uint64_t NewCount) {
+ Count = NewCount;
+ HasCount = true;
+ }
+};
+
/// \brief Partions mapping regions by their kind and sums
/// the execution counts of the regions that start at the same location.
class SourceCoverageDataManager {
std::vector<coverage::CountedRegion> Regions;
- bool Uniqued;
+ std::vector<CoverageSegment> Segments;
public:
- SourceCoverageDataManager() : Uniqued(false) {}
-
void insert(const coverage::CountedRegion &CR);
- /// \brief Return the source regions in order of first to last occurring.
- ArrayRef<coverage::CountedRegion> getSourceRegions();
+ /// \brief Return a sequence of non-overlapping coverage segments.
+ ArrayRef<CoverageSegment> getCoverageSegments();
};
} // namespace llvm
OpenPOWER on IntegriCloud