From cdc939779e850103f5958c242b146c83f860eb26 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Fri, 28 Jun 2019 15:38:25 +0000 Subject: [PATCH] [llvm-cov[ Fix lcov coverage report contains functions from other compilation 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364653 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/llvm-cov/multiple-files.test | 12 ++++++++++++ tools/llvm-cov/CoverageExporterLcov.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/tools/llvm-cov/multiple-files.test b/test/tools/llvm-cov/multiple-files.test index d0dbdd8c0fcf..37df8d2b8eda 100644 --- a/test/tools/llvm-cov/multiple-files.test +++ b/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: --- @@ -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 diff --git a/tools/llvm-cov/CoverageExporterLcov.cpp b/tools/llvm-cov/CoverageExporterLcov.cpp index 6e017743eec8..d9b0c3b0d7a8 100644 --- a/tools/llvm-cov/CoverageExporterLcov.cpp +++ b/tools/llvm-cov/CoverageExporterLcov.cpp @@ -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);