summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/CoverageSummary.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-11-14 01:50:32 +0000
committerJustin Bogner <mail@justinbogner.com>2014-11-14 01:50:32 +0000
commitd5fca9242501b708483efaf62e0f8ad86518569d (patch)
tree84c6ed701289d60c52295c1082088d691ab1c043 /llvm/tools/llvm-cov/CoverageSummary.cpp
parentd3be12a6c7e89955d6f528a7ba3d1966309b7853 (diff)
downloadbcm5719-llvm-d5fca9242501b708483efaf62e0f8ad86518569d.tar.gz
bcm5719-llvm-d5fca9242501b708483efaf62e0f8ad86518569d.zip
llvm-cov: Sink some reporting logic into CoverageMapping
This teaches CoverageMapping::getCoveredFunctions to filter to a particular file and uses that to replace most of the logic found in llvm-cov report. llvm-svn: 221962
Diffstat (limited to 'llvm/tools/llvm-cov/CoverageSummary.cpp')
-rw-r--r--llvm/tools/llvm-cov/CoverageSummary.cpp46
1 files changed, 9 insertions, 37 deletions
diff --git a/llvm/tools/llvm-cov/CoverageSummary.cpp b/llvm/tools/llvm-cov/CoverageSummary.cpp
index 785e9024ba7..059c8c857e4 100644
--- a/llvm/tools/llvm-cov/CoverageSummary.cpp
+++ b/llvm/tools/llvm-cov/CoverageSummary.cpp
@@ -28,44 +28,16 @@ unsigned CoverageSummary::getFileID(StringRef Filename) {
}
void
-CoverageSummary::createSummaries(ArrayRef<coverage::FunctionRecord> Functions) {
- std::vector<std::pair<unsigned, size_t>> FunctionFileIDs;
-
- FunctionFileIDs.resize(Functions.size());
- for (size_t I = 0, E = Functions.size(); I < E; ++I) {
- StringRef Filename = Functions[I].Filenames[0];
- FunctionFileIDs[I] = std::make_pair(getFileID(Filename), I);
- }
-
- // Sort the function records by file ids
- std::sort(FunctionFileIDs.begin(), FunctionFileIDs.end(),
- [](const std::pair<unsigned, size_t> &lhs,
- const std::pair<unsigned, size_t> &rhs) {
- return lhs.first < rhs.first;
- });
-
- // Create function summaries in a sorted order (by file ids)
- FunctionSummaries.reserve(Functions.size());
- for (size_t I = 0, E = Functions.size(); I < E; ++I)
- FunctionSummaries.push_back(
- FunctionCoverageSummary::get(Functions[FunctionFileIDs[I].second]));
-
- // Create file summaries
- size_t CurrentSummary = 0;
- for (unsigned FileID = 0; FileID < Filenames.size(); ++FileID) {
- // Gather the relevant functions summaries
- auto PrevSummary = CurrentSummary;
- while (CurrentSummary < FunctionSummaries.size() &&
- FunctionFileIDs[CurrentSummary].first == FileID)
- ++CurrentSummary;
- ArrayRef<FunctionCoverageSummary> LocalSummaries(
- FunctionSummaries.data() + PrevSummary,
- FunctionSummaries.data() + CurrentSummary);
- if (LocalSummaries.empty())
+CoverageSummary::createSummaries(const coverage::CoverageMapping &Coverage) {
+ for (StringRef Filename : Coverage.getUniqueSourceFiles()) {
+ size_t PrevSize = FunctionSummaries.size();
+ for (const auto &F : Coverage.getCoveredFunctions(Filename))
+ FunctionSummaries.push_back(FunctionCoverageSummary::get(F));
+ size_t Count = FunctionSummaries.size() - PrevSize;
+ if (Count == 0)
continue;
-
- FileSummaries.push_back(
- FileCoverageSummary::get(Filenames[FileID], LocalSummaries));
+ FileSummaries.push_back(FileCoverageSummary::get(
+ Filename, makeArrayRef(FunctionSummaries.data() + PrevSize, Count)));
}
}
OpenPOWER on IntegriCloud