[llvm] 3c731ba - [llvm-cov] Allow commas in filenames passed to `-object` flag
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 13:46:39 PDT 2020
Author: Vedant Kumar
Date: 2020-09-18T13:46:29-07:00
New Revision: 3c731ba5f1b604c873e96ac137bfea723690ba95
URL: https://github.com/llvm/llvm-project/commit/3c731ba5f1b604c873e96ac137bfea723690ba95
DIFF: https://github.com/llvm/llvm-project/commit/3c731ba5f1b604c873e96ac137bfea723690ba95.diff
LOG: [llvm-cov] Allow commas in filenames passed to `-object` flag
Currently, -object takes a comma separated list of objects as an
argument, which prevents it working with path names that contain a
comma. Drop comma-separated support, which requires to set pass the
-object flag multiple times to set multiple objects.
Patch by Andrew Gallagher!
Differential Revision: https://reviews.llvm.org/D87003
Added:
llvm/test/tools/llvm-cov/comma-in-coverage-object-filename.test
Modified:
llvm/tools/llvm-cov/CodeCoverage.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-cov/comma-in-coverage-object-filename.test b/llvm/test/tools/llvm-cov/comma-in-coverage-object-filename.test
new file mode 100644
index 000000000000..0bcd3d175acc
--- /dev/null
+++ b/llvm/test/tools/llvm-cov/comma-in-coverage-object-filename.test
@@ -0,0 +1,3 @@
+RUN: llvm-cov show %t -instr-profile %t -dump-collected-objects -object a,b | FileCheck %s
+
+CHECK: a,b
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index b3c895b44a6d..cd3dbc44a66b 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -544,8 +544,11 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
cl::Positional, cl::desc("Covered executable or object file."));
cl::list<std::string> CovFilenames(
- "object", cl::desc("Coverage executable or object file"), cl::ZeroOrMore,
- cl::CommaSeparated);
+ "object", cl::desc("Coverage executable or object file"), cl::ZeroOrMore);
+
+ cl::opt<bool> DebugDumpCollectedObjects(
+ "dump-collected-objects", cl::Optional, cl::Hidden,
+ cl::desc("Show the collected coverage object files"));
cl::list<std::string> InputSourceFiles(
cl::Positional, cl::desc("<Source files>"), cl::ZeroOrMore);
@@ -668,6 +671,12 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
::exit(1);
}
+ if (DebugDumpCollectedObjects) {
+ for (StringRef OF : ObjectFilenames)
+ outs() << OF << '\n';
+ ::exit(0);
+ }
+
ViewOpts.Format = Format;
switch (ViewOpts.Format) {
case CoverageViewOptions::OutputFormat::Text:
More information about the llvm-commits
mailing list