[PATCH] D97061: [llvm-cov] Compare path only to find the same file
Choongwoo Han via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 11:26:30 PST 2021
tunz updated this revision to Diff 326755.
tunz added a comment.
rebase and add doc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97061/new/
https://reviews.llvm.org/D97061
Files:
llvm/docs/CommandGuide/llvm-cov.rst
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
@@ -135,6 +135,7 @@
CoverageViewOptions ViewOpts;
CoverageFiltersMatchAll Filters;
CoverageFilters IgnoreFilenameFilters;
+ bool ComparePathStringOnly = false;
/// True if InputSourceFiles are provided.
bool HadSourceFiles = false;
@@ -248,9 +249,22 @@
if (Loc != RemappedFilenames.end())
SourceFile = Loc->second;
}
- for (const auto &Files : LoadedSourceFiles)
- if (sys::fs::equivalent(SourceFile, Files.first))
- return *Files.second;
+
+ SmallString<256> NormalizedPath;
+ sys::path::native(SourceFile, NormalizedPath);
+ sys::path::remove_dots(NormalizedPath, true);
+ SourceFile = NormalizedPath;
+
+ if (ComparePathStringOnly) {
+ for (const auto &Files : LoadedSourceFiles)
+ if (SourceFile == Files.first)
+ return *Files.second;
+ } else {
+ for (const auto &Files : LoadedSourceFiles)
+ if (sys::fs::equivalent(SourceFile, Files.first))
+ return *Files.second;
+ }
+
auto Buffer = MemoryBuffer::getFile(SourceFile);
if (auto EC = Buffer.getError()) {
error(EC.message(), SourceFile);
@@ -654,6 +668,12 @@
"regular expression"),
cl::ZeroOrMore, cl::cat(FilteringCategory));
+ cl::opt<bool> IgnoreSymlinks(
+ "ignore-symlinks", cl::Optional,
+ cl::desc("Do not follow symlinks to check file equivalence. "
+ "Use only normalized path strings to find the same file."),
+ cl::init(false));
+
cl::opt<double> RegionCoverageLtFilter(
"region-coverage-lt", cl::Optional,
cl::desc("Show code coverage only for functions with region coverage "
@@ -838,6 +858,7 @@
::exit(0);
}
+ ComparePathStringOnly = IgnoreSymlinks;
ViewOpts.ShowBranchSummary = BranchSummary;
ViewOpts.ShowRegionSummary = RegionSummary;
ViewOpts.ShowInstantiationSummary = InstantiationSummary;
Index: llvm/docs/CommandGuide/llvm-cov.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-cov.rst
+++ llvm/docs/CommandGuide/llvm-cov.rst
@@ -264,6 +264,13 @@
Skip source code files with file paths that match the given regular expression.
+.. option:: -ignore-symlinks
+
+ Do not follow symbolic links to detect the same file. Following symbolic links
+ will generate an accurate report, but this could slow down processing time.
+ Thus, compare path strings only after normalization instead of following
+ symbolic links.
+
.. option:: -format=<FORMAT>
Use the specified output format. The supported formats are: "text", "html".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97061.326755.patch
Type: text/x-patch
Size: 2750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210226/18f73784/attachment.bin>
More information about the llvm-commits
mailing list