Skip to content

Commit

Permalink
[llvm-cov] Factor out logic to remove unmapped inputs (NFC)
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282286 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
vedantk committed Sep 23, 2016
1 parent a6754db commit 3de4fb3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tools/llvm-cov/CodeCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class CodeCoverageTool {
/// \brief Load the coverage mapping data. Return nullptr if an error occured.
std::unique_ptr<CoverageMapping> load();

/// \brief Remove input source files which aren't mapped by \p Coverage.
void removeUnmappedInputs(const CoverageMapping &Coverage);

/// \brief If a demangler is available, demangle all symbol names.
void demangleSymbols(const CoverageMapping &Coverage);

Expand Down Expand Up @@ -332,7 +335,16 @@ std::unique_ptr<CoverageMapping> CodeCoverageTool::load() {
if (Mismatched)
warning(utostr(Mismatched) + " functions have mismatched data");

std::vector<StringRef> CoveredFiles = Coverage.get()->getUniqueSourceFiles();
if (!SourceFiles.empty())
removeUnmappedInputs(*Coverage);

demangleSymbols(*Coverage);

return Coverage;
}

void CodeCoverageTool::removeUnmappedInputs(const CoverageMapping &Coverage) {
std::vector<StringRef> CoveredFiles = Coverage.getUniqueSourceFiles();

auto UncoveredFilesIt = SourceFiles.end();
if (!CompareFilenamesOnly) {
Expand Down Expand Up @@ -360,10 +372,6 @@ std::unique_ptr<CoverageMapping> CodeCoverageTool::load() {
}

SourceFiles.erase(UncoveredFilesIt, SourceFiles.end());

demangleSymbols(*Coverage);

return Coverage;
}

void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) {
Expand Down

0 comments on commit 3de4fb3

Please sign in to comment.