[llvm] r282282 - [llvm-cov] Filter away source files that aren't in the coverage mapping
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 11:57:35 PDT 2016
Author: vedantk
Date: Fri Sep 23 13:57:35 2016
New Revision: 282282
URL: http://llvm.org/viewvc/llvm-project?rev=282282&view=rev
Log:
[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.
Modified:
llvm/trunk/test/tools/llvm-cov/report.cpp
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
Modified: llvm/trunk/test/tools/llvm-cov/report.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/report.cpp?rev=282282&r1=282281&r2=282282&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/report.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/report.cpp Fri Sep 23 13:57:35 2016
@@ -1,5 +1,6 @@
// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence 2>&1 | FileCheck %s
-// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT-NEXT %s
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT %s
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -filename-equivalence report.cpp does-not-exist.cpp 2>&1 | FileCheck -check-prefix=FILT %s
// CHECK: Regions Missed Regions Cover Functions Missed Functions Executed Instantiations Missed Insts. Executed Lines Missed Lines Cover
// CHECK-NEXT: ---
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=282282&r1=282281&r2=282282&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Fri Sep 23 13:57:35 2016
@@ -332,19 +332,35 @@ std::unique_ptr<CoverageMapping> CodeCov
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;
More information about the llvm-commits
mailing list