Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 1 | //===- SourceCoverageDataManager.h - Manager for source file coverage data-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class separates and merges mapping regions for a specific source file. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_COV_SOURCECOVERAGEDATAMANAGER_H |
| 15 | #define LLVM_COV_SOURCECOVERAGEDATAMANAGER_H |
| 16 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 17 | #include "llvm/ProfileData/CoverageMapping.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 18 | #include <vector> |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | |
Justin Bogner | fe357c0 | 2014-09-17 18:23:47 +0000 | [diff] [blame] | 22 | struct CoverageSegment { |
| 23 | unsigned Line; |
| 24 | unsigned Col; |
| 25 | bool IsRegionEntry; |
| 26 | uint64_t Count; |
| 27 | bool HasCount; |
| 28 | |
| 29 | CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry) |
| 30 | : Line(Line), Col(Col), IsRegionEntry(IsRegionEntry), |
| 31 | Count(0), HasCount(false) {} |
| 32 | void setCount(uint64_t NewCount) { |
| 33 | Count = NewCount; |
| 34 | HasCount = true; |
| 35 | } |
| 36 | }; |
| 37 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 38 | /// \brief Partions mapping regions by their kind and sums |
| 39 | /// the execution counts of the regions that start at the same location. |
| 40 | class SourceCoverageDataManager { |
Justin Bogner | e53be06 | 2014-09-09 05:32:18 +0000 | [diff] [blame] | 41 | std::vector<coverage::CountedRegion> Regions; |
Justin Bogner | fe357c0 | 2014-09-17 18:23:47 +0000 | [diff] [blame] | 42 | std::vector<CoverageSegment> Segments; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 43 | |
| 44 | public: |
Justin Bogner | 8e8aa3f | 2014-09-09 05:32:14 +0000 | [diff] [blame] | 45 | void insert(const coverage::CountedRegion &CR); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 46 | |
Justin Bogner | fe357c0 | 2014-09-17 18:23:47 +0000 | [diff] [blame] | 47 | /// \brief Return a sequence of non-overlapping coverage segments. |
| 48 | ArrayRef<CoverageSegment> getCoverageSegments(); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace llvm |
| 52 | |
| 53 | #endif // LLVM_COV_SOURCECOVERAGEDATAMANAGER_H |