diff options
| author | Justin Bogner <mail@justinbogner.com> | 2015-02-14 02:01:24 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2015-02-14 02:01:24 +0000 |
| commit | f91bc6cdd87556fecc68cb95693fc0e37a15231a (patch) | |
| tree | cde984d2621589e809cc4f3c266053828890d22f /llvm/tools/llvm-cov/CoverageSummaryInfo.cpp | |
| parent | 5975a703e6657784339e25fcf84a745e9342668a (diff) | |
| download | bcm5719-llvm-f91bc6cdd87556fecc68cb95693fc0e37a15231a.tar.gz bcm5719-llvm-f91bc6cdd87556fecc68cb95693fc0e37a15231a.zip | |
llvm-cov: Simplify coverage reports, fixing PR22575 in the process
PR22575 occurred because we were unsafely storing references into a
std::vector. If the vector moved because it grew, we'd be left
iterating through garbage memory. This avoids the issue by simplifying
the logic to gather coverage information as we go, rather than storing
it and iterating over it.
I'm relying on the existing tests showing that this is semantically
NFC, since it's difficult to hit the issue this fixes without
relatively large covered programs.
llvm-svn: 229215
Diffstat (limited to 'llvm/tools/llvm-cov/CoverageSummaryInfo.cpp')
| -rw-r--r-- | llvm/tools/llvm-cov/CoverageSummaryInfo.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp index dd78ace8605..de8975097e4 100644 --- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp +++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp @@ -69,28 +69,3 @@ FunctionCoverageSummary::get(const coverage::FunctionRecord &Function) { RegionCoverageInfo(CoveredRegions, NumCodeRegions), LineCoverageInfo(CoveredLines, 0, NumLines)); } - -FileCoverageSummary -FileCoverageSummary::get(StringRef Name, - ArrayRef<FunctionCoverageSummary> FunctionSummaries) { - size_t NumRegions = 0, CoveredRegions = 0; - size_t NumLines = 0, NonCodeLines = 0, CoveredLines = 0; - size_t NumFunctionsExecuted = 0; - for (const auto &Func : FunctionSummaries) { - CoveredRegions += Func.RegionCoverage.Covered; - NumRegions += Func.RegionCoverage.NumRegions; - - CoveredLines += Func.LineCoverage.Covered; - NonCodeLines += Func.LineCoverage.NonCodeLines; - NumLines += Func.LineCoverage.NumLines; - - if (Func.ExecutionCount != 0) - ++NumFunctionsExecuted; - } - - return FileCoverageSummary( - Name, RegionCoverageInfo(CoveredRegions, NumRegions), - LineCoverageInfo(CoveredLines, NonCodeLines, NumLines), - FunctionCoverageInfo(NumFunctionsExecuted, FunctionSummaries.size()), - FunctionSummaries); -} |

