aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-cov/CoverageSummaryInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-cov/CoverageSummaryInfo.h')
-rw-r--r--tools/llvm-cov/CoverageSummaryInfo.h53
1 files changed, 38 insertions, 15 deletions
diff --git a/tools/llvm-cov/CoverageSummaryInfo.h b/tools/llvm-cov/CoverageSummaryInfo.h
index 0036032..c393b00 100644
--- a/tools/llvm-cov/CoverageSummaryInfo.h
+++ b/tools/llvm-cov/CoverageSummaryInfo.h
@@ -31,10 +31,19 @@ struct RegionCoverageInfo {
/// \brief The total number of regions in a function/file.
size_t NumRegions;
+ RegionCoverageInfo() : Covered(0), NotCovered(0), NumRegions(0) {}
+
RegionCoverageInfo(size_t Covered, size_t NumRegions)
: Covered(Covered), NotCovered(NumRegions - Covered),
NumRegions(NumRegions) {}
+ RegionCoverageInfo &operator+=(const RegionCoverageInfo &RHS) {
+ Covered += RHS.Covered;
+ NotCovered += RHS.NotCovered;
+ NumRegions += RHS.NumRegions;
+ return *this;
+ }
+
bool isFullyCovered() const { return Covered == NumRegions; }
double getPercentCovered() const {
@@ -56,10 +65,21 @@ struct LineCoverageInfo {
/// \brief The total number of lines in a function/file.
size_t NumLines;
+ LineCoverageInfo()
+ : Covered(0), NotCovered(0), NonCodeLines(0), NumLines(0) {}
+
LineCoverageInfo(size_t Covered, size_t NumNonCodeLines, size_t NumLines)
: Covered(Covered), NotCovered(NumLines - NumNonCodeLines - Covered),
NonCodeLines(NumNonCodeLines), NumLines(NumLines) {}
+ LineCoverageInfo &operator+=(const LineCoverageInfo &RHS) {
+ Covered += RHS.Covered;
+ NotCovered += RHS.NotCovered;
+ NonCodeLines += RHS.NonCodeLines;
+ NumLines += RHS.NumLines;
+ return *this;
+ }
+
bool isFullyCovered() const { return Covered == (NumLines - NonCodeLines); }
double getPercentCovered() const {
@@ -75,9 +95,17 @@ struct FunctionCoverageInfo {
/// \brief The total number of functions in this file.
size_t NumFunctions;
+ FunctionCoverageInfo() : Executed(0), NumFunctions(0) {}
+
FunctionCoverageInfo(size_t Executed, size_t NumFunctions)
: Executed(Executed), NumFunctions(NumFunctions) {}
+ void addFunction(bool Covered) {
+ if (Covered)
+ ++Executed;
+ ++NumFunctions;
+ }
+
bool isFullyCovered() const { return Executed == NumFunctions; }
double getPercentCovered() const {
@@ -92,6 +120,8 @@ struct FunctionCoverageSummary {
RegionCoverageInfo RegionCoverage;
LineCoverageInfo LineCoverage;
+ FunctionCoverageSummary(StringRef Name) : Name(Name), ExecutionCount(0) {}
+
FunctionCoverageSummary(StringRef Name, uint64_t ExecutionCount,
const RegionCoverageInfo &RegionCoverage,
const LineCoverageInfo &LineCoverage)
@@ -111,21 +141,14 @@ struct FileCoverageSummary {
RegionCoverageInfo RegionCoverage;
LineCoverageInfo LineCoverage;
FunctionCoverageInfo FunctionCoverage;
- /// \brief The summary of every function
- /// in this file.
- ArrayRef<FunctionCoverageSummary> FunctionSummaries;
-
- FileCoverageSummary(StringRef Name, const RegionCoverageInfo &RegionCoverage,
- const LineCoverageInfo &LineCoverage,
- const FunctionCoverageInfo &FunctionCoverage,
- ArrayRef<FunctionCoverageSummary> FunctionSummaries)
- : Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage),
- FunctionCoverage(FunctionCoverage),
- FunctionSummaries(FunctionSummaries) {}
-
- /// \brief Compute the code coverage summary for a file.
- static FileCoverageSummary
- get(StringRef Name, ArrayRef<FunctionCoverageSummary> FunctionSummaries);
+
+ FileCoverageSummary(StringRef Name) : Name(Name) {}
+
+ void addFunction(const FunctionCoverageSummary &Function) {
+ RegionCoverage += Function.RegionCoverage;
+ LineCoverage += Function.LineCoverage;
+ FunctionCoverage.addFunction(/*Covered=*/Function.ExecutionCount > 0);
+ }
};
} // namespace llvm