Skip to content

Commit

Permalink
[llvm-cov[ Fix lcov coverage report contains functions from other com…
Browse files Browse the repository at this point in the history
…pilation units.

Summary: Patch by Chuan Qiu (@eagleonhill).

Reviewers: Dor1s

Reviewed By: Dor1s

Subscribers: lebedev.ri, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63571

llvm-svn: 364653
  • Loading branch information
Dor1s committed Jun 28, 2019
1 parent 9f1dffd commit 176b9f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions llvm/test/tools/llvm-cov/multiple-files.test
@@ -1,6 +1,7 @@
// RUN: llvm-profdata merge %S/Inputs/multiple-files.proftext -o %t.profdata
// RUN: llvm-cov report %S/Inputs/multiple-files.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefix=MANY_COMPONENTS
// RUN: llvm-cov report %S/Inputs/multiple-files2.covmapping -instr-profile %t.profdata | FileCheck %s -check-prefix=ONE_COMPONENT
// RUN: llvm-cov export %S/Inputs/multiple-files.covmapping -instr-profile %t.profdata -format=lcov | FileCheck %s -check-prefix=LCOV

// MANY_COMPONENTS: Filename
// MANY_COMPONENTS-NEXT: ---
Expand All @@ -13,3 +14,14 @@
// ONE_COMPONENT-NEXT: ---
// ONE_COMPONENT-NEXT: {{^}}cov.c
// ONE_COMPONENT-NEXT: {{^}}cov.h

// LCOV-LABEL: SF:{{.*}}a{{[/\\]}}f2.c
// LCOV: FN:1,f2
// No extra funcs
// LCOV-NOT: FN:
// LCOV-LABEL: SF:{{.*}}b{{[/\\]}}c{{[/\\]}}f4.c
// LCOV: FN:1,f4
// LCOV-LABEL: SF:{{.*}}b{{[/\\]}}f3.c
// LCOV: FN:1,f3
// LCOV-LABEL: SF:{{.*}}f1.c
// LCOV: FN:1,f1
2 changes: 1 addition & 1 deletion llvm/tools/llvm-cov/CoverageExporterLcov.cpp
Expand Up @@ -82,7 +82,7 @@ void renderFile(raw_ostream &OS, const coverage::CoverageMapping &Coverage,
OS << "SF:" << Filename << '\n';

if (!ExportSummaryOnly) {
renderFunctions(OS, Coverage.getCoveredFunctions());
renderFunctions(OS, Coverage.getCoveredFunctions(Filename));
}
renderFunctionSummary(OS, FileReport);

Expand Down

0 comments on commit 176b9f6

Please sign in to comment.