diff options
author | Alex Lorenz <arphaman@gmail.com> | 2014-09-30 12:45:13 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2014-09-30 12:45:13 +0000 |
commit | cb1702d45a433689f297567b1bcba03378bbd9f2 (patch) | |
tree | f2ab574484c3c140ed1485a1dd792abfab6be9d2 /llvm/tools/llvm-cov | |
parent | 40d3deeb7da108f16dbdcb5f83e718607c07f5f8 (diff) | |
download | bcm5719-llvm-cb1702d45a433689f297567b1bcba03378bbd9f2.tar.gz bcm5719-llvm-cb1702d45a433689f297567b1bcba03378bbd9f2.zip |
llvm-cov: Use the number of executed functions for the function coverage metric.
This commit fixes llvm-cov's function coverage metric by using the number of executed functions instead of the number of fully covered functions.
Differential Revision: http://reviews.llvm.org/D5196
llvm-svn: 218672
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r-- | llvm/tools/llvm-cov/CoverageReport.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageSummary.cpp | 6 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.cpp | 11 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.h | 19 |
4 files changed, 24 insertions, 21 deletions
diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp index 2efa8e00798..94071b7367e 100644 --- a/llvm/tools/llvm-cov/CoverageReport.cpp +++ b/llvm/tools/llvm-cov/CoverageReport.cpp @@ -85,7 +85,7 @@ static Column column(StringRef Str, unsigned Width, const T &Value) { return Column(Str, Width).set(Value); } -static const unsigned FileReportColumns[] = {25, 10, 8, 8, 10, 8}; +static const unsigned FileReportColumns[] = {25, 10, 8, 8, 10, 10}; static const unsigned FunctionReportColumns[] = {25, 10, 8, 8, 10, 8, 8}; /// \brief Prints a horizontal divider which spans across the given columns. @@ -178,8 +178,8 @@ void CoverageReport::renderFunctionReports(raw_ostream &OS) { render(Function, OS); renderDivider(FunctionReportColumns, OS); OS << "\n"; - render(FunctionCoverageSummary("TOTAL", File.RegionCoverage, - File.LineCoverage), + render(FunctionCoverageSummary("TOTAL", /*ExecutionCount=*/0, + File.RegionCoverage, File.LineCoverage), OS); } } @@ -190,7 +190,8 @@ void CoverageReport::renderFileReports(raw_ostream &OS) { << column("Miss", FileReportColumns[2], Column::RightAlignment) << column("Cover", FileReportColumns[3], Column::RightAlignment) << column("Functions", FileReportColumns[4], Column::RightAlignment) - << column("Cover", FileReportColumns[5], Column::RightAlignment) << "\n"; + << column("Executed", FileReportColumns[5], Column::RightAlignment) + << "\n"; renderDivider(FileReportColumns, OS); OS << "\n"; for (const auto &File : Summary.getFileSummaries()) diff --git a/llvm/tools/llvm-cov/CoverageSummary.cpp b/llvm/tools/llvm-cov/CoverageSummary.cpp index 8df3bebbacf..785e9024ba7 100644 --- a/llvm/tools/llvm-cov/CoverageSummary.cpp +++ b/llvm/tools/llvm-cov/CoverageSummary.cpp @@ -72,7 +72,7 @@ CoverageSummary::createSummaries(ArrayRef<coverage::FunctionRecord> Functions) { FileCoverageSummary CoverageSummary::getCombinedFileSummaries() { size_t NumRegions = 0, CoveredRegions = 0; size_t NumLines = 0, NonCodeLines = 0, CoveredLines = 0; - size_t NumFunctionsCovered = 0, NumFunctions = 0; + size_t NumFunctionsExecuted = 0, NumFunctions = 0; for (const auto &File : FileSummaries) { NumRegions += File.RegionCoverage.NumRegions; CoveredRegions += File.RegionCoverage.Covered; @@ -81,12 +81,12 @@ FileCoverageSummary CoverageSummary::getCombinedFileSummaries() { NonCodeLines += File.LineCoverage.NonCodeLines; CoveredLines += File.LineCoverage.Covered; - NumFunctionsCovered += File.FunctionCoverage.FullyCovered; + NumFunctionsExecuted += File.FunctionCoverage.Executed; NumFunctions += File.FunctionCoverage.NumFunctions; } return FileCoverageSummary( "TOTAL", RegionCoverageInfo(CoveredRegions, NumRegions), LineCoverageInfo(CoveredLines, NonCodeLines, NumLines), - FunctionCoverageInfo(NumFunctionsCovered, NumFunctions), + FunctionCoverageInfo(NumFunctionsExecuted, NumFunctions), None); } diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp index 334bc73e0d9..dd78ace8605 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp @@ -65,7 +65,8 @@ FunctionCoverageSummary::get(const coverage::FunctionRecord &Function) { NumLines += LineCount; } return FunctionCoverageSummary( - Function.Name, RegionCoverageInfo(CoveredRegions, NumCodeRegions), + Function.Name, Function.ExecutionCount, + RegionCoverageInfo(CoveredRegions, NumCodeRegions), LineCoverageInfo(CoveredLines, 0, NumLines)); } @@ -74,7 +75,7 @@ FileCoverageSummary::get(StringRef Name, ArrayRef<FunctionCoverageSummary> FunctionSummaries) { size_t NumRegions = 0, CoveredRegions = 0; size_t NumLines = 0, NonCodeLines = 0, CoveredLines = 0; - size_t NumFunctionsCovered = 0; + size_t NumFunctionsExecuted = 0; for (const auto &Func : FunctionSummaries) { CoveredRegions += Func.RegionCoverage.Covered; NumRegions += Func.RegionCoverage.NumRegions; @@ -83,13 +84,13 @@ FileCoverageSummary::get(StringRef Name, NonCodeLines += Func.LineCoverage.NonCodeLines; NumLines += Func.LineCoverage.NumLines; - if (Func.RegionCoverage.isFullyCovered()) - ++NumFunctionsCovered; + if (Func.ExecutionCount != 0) + ++NumFunctionsExecuted; } return FileCoverageSummary( Name, RegionCoverageInfo(CoveredRegions, NumRegions), LineCoverageInfo(CoveredLines, NonCodeLines, NumLines), - FunctionCoverageInfo(NumFunctionsCovered, FunctionSummaries.size()), + FunctionCoverageInfo(NumFunctionsExecuted, FunctionSummaries.size()), FunctionSummaries); } diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.h b/llvm/tools/llvm-cov/CoverageSummaryInfo.h index 18b270433cd..0036032ab39 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.h +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.h @@ -69,33 +69,34 @@ struct LineCoverageInfo { /// \brief Provides information about function coverage for a file. struct FunctionCoverageInfo { - /// \brief The number of functions that have full - /// region coverage. - size_t FullyCovered; + /// \brief The number of functions that were executed. + size_t Executed; /// \brief The total number of functions in this file. size_t NumFunctions; - FunctionCoverageInfo(size_t FullyCovered, size_t NumFunctions) - : FullyCovered(FullyCovered), NumFunctions(NumFunctions) {} + FunctionCoverageInfo(size_t Executed, size_t NumFunctions) + : Executed(Executed), NumFunctions(NumFunctions) {} - bool isFullyCovered() const { return FullyCovered == NumFunctions; } + bool isFullyCovered() const { return Executed == NumFunctions; } double getPercentCovered() const { - return double(FullyCovered) / double(NumFunctions) * 100.0; + return double(Executed) / double(NumFunctions) * 100.0; } }; /// \brief A summary of function's code coverage. struct FunctionCoverageSummary { StringRef Name; + uint64_t ExecutionCount; RegionCoverageInfo RegionCoverage; LineCoverageInfo LineCoverage; - FunctionCoverageSummary(StringRef Name, + FunctionCoverageSummary(StringRef Name, uint64_t ExecutionCount, const RegionCoverageInfo &RegionCoverage, const LineCoverageInfo &LineCoverage) - : Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) { + : Name(Name), ExecutionCount(ExecutionCount), + RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) { } /// \brief Compute the code coverage summary for the given function coverage |