[llvm-cov] Allow commas in filenames passed to `-object` flag
authorVedant Kumar <vsk@apple.com>
Fri, 18 Sep 2020 20:43:49 +0000 (13:43 -0700)
committerVedant Kumar <vsk@apple.com>
Fri, 18 Sep 2020 20:46:29 +0000 (13:46 -0700)
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

llvm/test/tools/llvm-cov/comma-in-coverage-object-filename.test [new file with mode: 0644]
llvm/tools/llvm-cov/CodeCoverage.cpp

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 (file)
index 0000000..0bcd3d1
--- /dev/null
@@ -0,0 +1,3 @@
+RUN: llvm-cov show %t -instr-profile %t -dump-collected-objects -object a,b | FileCheck %s
+
+CHECK: a,b
index b3c895b..cd3dbc4 100644 (file)
@@ -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: