diff options
| author | Vedant Kumar <vsk@apple.com> | 2017-09-15 23:00:01 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2017-09-15 23:00:01 +0000 |
| commit | c445e65d0969dba334b4b1cb545457f98f5c654c (patch) | |
| tree | 12f2343756f774c0d780d3fa08d9b5b6fb708461 /llvm/tools/llvm-cov/CoverageSummaryInfo.h | |
| parent | b84e48447e4456bb29261b7380d9696bcf29f511 (diff) | |
| download | bcm5719-llvm-c445e65d0969dba334b4b1cb545457f98f5c654c.tar.gz bcm5719-llvm-c445e65d0969dba334b4b1cb545457f98f5c654c.zip | |
[llvm-cov] Make some summary info fields private. NFC.
There's a bug in the way the line and region summary objects are merged.
It would have been less likely to occur if those objects kept some data
private.
llvm-svn: 313416
Diffstat (limited to 'llvm/tools/llvm-cov/CoverageSummaryInfo.h')
| -rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.h | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.h b/llvm/tools/llvm-cov/CoverageSummaryInfo.h index 91b9f62d3d9..b3385fcb327 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.h +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.h @@ -21,13 +21,14 @@ namespace llvm { /// \brief Provides information about region coverage for a function/file. -struct RegionCoverageInfo { +class RegionCoverageInfo { /// \brief The number of regions that were executed at least once. size_t Covered; /// \brief The total number of regions in a function/file. size_t NumRegions; +public: RegionCoverageInfo() : Covered(0), NumRegions(0) {} RegionCoverageInfo(size_t Covered, size_t NumRegions) @@ -39,6 +40,14 @@ struct RegionCoverageInfo { return *this; } + void merge(const RegionCoverageInfo &RHS) { + Covered = std::max(Covered, RHS.Covered); + } + + size_t getCovered() const { return Covered; } + + size_t getNumRegions() const { return NumRegions; } + bool isFullyCovered() const { return Covered == NumRegions; } double getPercentCovered() const { @@ -49,13 +58,14 @@ struct RegionCoverageInfo { }; /// \brief Provides information about line coverage for a function/file. -struct LineCoverageInfo { +class LineCoverageInfo { /// \brief The number of lines that were executed at least once. size_t Covered; /// \brief The total number of lines in a function/file. size_t NumLines; +public: LineCoverageInfo() : Covered(0), NumLines(0) {} LineCoverageInfo(size_t Covered, size_t NumLines) @@ -67,6 +77,14 @@ struct LineCoverageInfo { return *this; } + void merge(const LineCoverageInfo &RHS) { + Covered = std::max(Covered, RHS.Covered); + } + + size_t getCovered() const { return Covered; } + + size_t getNumLines() const { return NumLines; } + bool isFullyCovered() const { return Covered == NumLines; } double getPercentCovered() const { @@ -77,13 +95,14 @@ struct LineCoverageInfo { }; /// \brief Provides information about function coverage for a file. -struct FunctionCoverageInfo { +class FunctionCoverageInfo { /// \brief The number of functions that were executed. size_t Executed; /// \brief The total number of functions in this file. size_t NumFunctions; +public: FunctionCoverageInfo() : Executed(0), NumFunctions(0) {} FunctionCoverageInfo(size_t Executed, size_t NumFunctions) @@ -95,6 +114,10 @@ struct FunctionCoverageInfo { ++NumFunctions; } + size_t getExecuted() const { return Executed; } + + size_t getNumFunctions() const { return NumFunctions; } + bool isFullyCovered() const { return Executed == NumFunctions; } double getPercentCovered() const { |

