diff options
author | Vedant Kumar <vsk@apple.com> | 2016-09-23 18:57:35 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2016-09-23 18:57:35 +0000 |
commit | daacf3c8baf767e1b362e1510c3f0072693f64fa (patch) | |
tree | 2e086ee702d1a26711b799ff3349edeaff2d78ab /tools/llvm-cov/CodeCoverage.cpp | |
parent | fd066351a5eb34b4cd04741be998094ffad95ce9 (diff) |
[llvm-cov] Filter away source files that aren't in the coverage mapping
... so that they don't show up in the index. This came up because polly
contains a .git directory and some other unmapped input in its source
dir.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282282 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r-- | tools/llvm-cov/CodeCoverage.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp index 51ac6ef3d88..9230d01778c 100644 --- a/tools/llvm-cov/CodeCoverage.cpp +++ b/tools/llvm-cov/CodeCoverage.cpp @@ -332,19 +332,35 @@ std::unique_ptr<CoverageMapping> CodeCoverageTool::load() { if (Mismatched) warning(utostr(Mismatched) + " functions have mismatched data"); - if (CompareFilenamesOnly) { - auto CoveredFiles = Coverage.get()->getUniqueSourceFiles(); + std::vector<StringRef> CoveredFiles = Coverage.get()->getUniqueSourceFiles(); + + auto UncoveredFilesIt = SourceFiles.end(); + if (!CompareFilenamesOnly) { + // The user may have specified source files which aren't in the coverage + // mapping. Filter these files away. + UncoveredFilesIt = std::remove_if( + SourceFiles.begin(), SourceFiles.end(), [&](const std::string &SF) { + return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(), + SF); + }); + } else { for (auto &SF : SourceFiles) { StringRef SFBase = sys::path::filename(SF); - for (const auto &CF : CoveredFiles) + for (const auto &CF : CoveredFiles) { if (SFBase == sys::path::filename(CF)) { RemappedFilenames[CF] = SF; SF = CF; break; } + } } + UncoveredFilesIt = std::remove_if( + SourceFiles.begin(), SourceFiles.end(), + [&](const std::string &SF) { return !RemappedFilenames.count(SF); }); } + SourceFiles.erase(UncoveredFilesIt, SourceFiles.end()); + demangleSymbols(*Coverage); return Coverage; |