summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2016-09-23 18:57:35 +0000
committerVedant Kumar <vsk@apple.com>2016-09-23 18:57:35 +0000
commit458808805091f0f7e73a4d91c72e909f1d49a7eb (patch)
treede903dd66b2ad9606428b9b8bf2af56a1df5e6d6 /llvm/tools/llvm-cov
parentbc6479850e1d4a4522c6d195f93704d3e78e54e3 (diff)
downloadbcm5719-llvm-458808805091f0f7e73a4d91c72e909f1d49a7eb.tar.gz
bcm5719-llvm-458808805091f0f7e73a4d91c72e909f1d49a7eb.zip
[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. llvm-svn: 282282
Diffstat (limited to 'llvm/tools/llvm-cov')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 51ac6ef3d88..9230d01778c 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud