[PATCH] D89359: [llvm-cov] don't include all source files when provided source files are filtered out
Zequan Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 15 18:11:24 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd3090819c4e: [llvm-cov] don't include all source files when provided source files areā¦ (authored by zequanwu).
Changed prior to commit:
https://reviews.llvm.org/D89359?vs=298270&id=298531#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89359/new/
https://reviews.llvm.org/D89359
Files:
llvm/test/tools/llvm-cov/sources-specified.test
llvm/test/tools/llvm-cov/universal_bin_wrapping_archives.test
llvm/tools/llvm-cov/CodeCoverage.cpp
Index: llvm/tools/llvm-cov/CodeCoverage.cpp
===================================================================
--- llvm/tools/llvm-cov/CodeCoverage.cpp
+++ llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -130,6 +130,9 @@
CoverageFiltersMatchAll Filters;
CoverageFilters IgnoreFilenameFilters;
+ /// True if InputSourceFiles are provided.
+ bool HadSourceFiles = false;
+
/// The path to the indexed profile.
std::string PGOFilename;
@@ -194,6 +197,7 @@
sys::path::remove_dots(EffectivePath, /*remove_dot_dots=*/true);
if (!IgnoreFilenameFilters.matchesFilename(EffectivePath))
SourceFiles.emplace_back(EffectivePath.str());
+ HadSourceFiles = !SourceFiles.empty();
}
void CodeCoverageTool::collectPaths(const std::string &Path) {
@@ -397,6 +401,7 @@
sys::path::native(Path, NativePath);
if (!sys::path::is_separator(NativePath.back()))
NativePath += sys::path::get_separator();
+ sys::path::remove_dots(NativePath, true);
return NativePath.c_str();
};
std::string RemapFrom = nativeWithTrailing(PathRemapping->first);
@@ -406,6 +411,7 @@
for (StringRef Filename : Coverage.getUniqueSourceFiles()) {
SmallString<128> NativeFilename;
sys::path::native(Filename, NativeFilename);
+ sys::path::remove_dots(NativeFilename, true);
if (NativeFilename.startswith(RemapFrom)) {
RemappedFilenames[Filename] =
RemapTo + NativeFilename.substr(RemapFrom.size()).str();
@@ -895,7 +901,7 @@
auto Printer = CoveragePrinter::create(ViewOpts);
- if (SourceFiles.empty())
+ if (SourceFiles.empty() && !HadSourceFiles)
// Get the source files from the function coverage mapping.
for (StringRef Filename : Coverage->getUniqueSourceFiles()) {
if (!IgnoreFilenameFilters.matchesFilename(Filename))
Index: llvm/test/tools/llvm-cov/universal_bin_wrapping_archives.test
===================================================================
--- llvm/test/tools/llvm-cov/universal_bin_wrapping_archives.test
+++ llvm/test/tools/llvm-cov/universal_bin_wrapping_archives.test
@@ -17,11 +17,11 @@
RUN: llvm-profdata merge %S/Inputs/universal_bin_wrapping_archives/universal_bin_wrapping_archives.proftext -o %t.profdata
RUN: llvm-cov show %S/Inputs/universal_bin_wrapping_archives/universal_bin_wrapping_archives \
-RUN: -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs/universal_bin_wrapping_archives %s -arch i386 \
+RUN: -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs/universal_bin_wrapping_archives -arch i386 \
RUN: | FileCheck %s --check-prefix=SHOW_ARCHIVE
RUN: llvm-cov show %S/Inputs/universal_bin_wrapping_archives/universal_bin_wrapping_archives \
-RUN: -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs/universal_bin_wrapping_archives %s -arch x86_64 \
+RUN: -instr-profile %t.profdata -path-equivalence=/tmp,%S/Inputs/universal_bin_wrapping_archives -arch x86_64 \
RUN: | FileCheck %s --check-prefix=SHOW_ARCHIVE
SHOW_ARCHIVE: {{.*}}obj1.c:
Index: llvm/test/tools/llvm-cov/sources-specified.test
===================================================================
--- llvm/test/tools/llvm-cov/sources-specified.test
+++ llvm/test/tools/llvm-cov/sources-specified.test
@@ -10,6 +10,18 @@
RUN: %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
RUN: | FileCheck -check-prefix=SHOW %s
+# Don't include all source files when provided source files are filtered out.
+RUN: llvm-cov show -instr-profile %S/Inputs/sources_specified/main.profdata \
+RUN: -path-equivalence=/tmp,%S/Inputs \
+RUN: %S/Inputs/sources_specified/main.covmapping \
+RUN: --ignore-filename-regex='.*' \
+RUN: %S/Inputs/sources_specified/main.cc %S/Inputs/sources_specified/extra \
+RUN: | FileCheck -allow-empty -check-prefix=IGNORE %s
+
+IGNORE-NOT: {{.*}}main.cc{{.*}}
+IGNORE-NOT: {{.*}}inc.h{{.*}}
+IGNORE-NOT: {{.*}}dec.h{{.*}}
+
# Order of files may differ, check the total values calculated.
REPORT-NOT: {{.*}}abs.h{{.*}}
REPORT: {{^}}TOTAL 3{{.*}}72.73%
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89359.298531.patch
Type: text/x-patch
Size: 4032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201016/4f1c30a2/attachment.bin>
More information about the llvm-commits
mailing list