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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner
2014-11-14 01:50:32 +00:00
parent 4a7bbf4c29
commit d24e90a5de
5 changed files with 66 additions and 43 deletions

View File

@@ -170,6 +170,14 @@ ErrorOr<int64_t> CounterMappingContext::evaluate(const Counter &C) const {
llvm_unreachable("Unhandled CounterKind");
}
void FunctionRecordIterator::skipOtherFiles() {
while (Current != Records.end() && !Filename.empty() &&
Filename != Current->Filenames[0])
++Current;
if (Current == Records.end())
*this = FunctionRecordIterator();
}
ErrorOr<std::unique_ptr<CoverageMapping>>
CoverageMapping::load(ObjectFileCoverageMappingReader &CoverageReader,
IndexedInstrProfReader &ProfileReader) {
@@ -320,7 +328,7 @@ public:
};
}
std::vector<StringRef> CoverageMapping::getUniqueSourceFiles() {
std::vector<StringRef> CoverageMapping::getUniqueSourceFiles() const {
std::vector<StringRef> Filenames;
for (const auto &Function : getCoveredFunctions())
for (const auto &Filename : Function.Filenames)