[PATCH] D109042: [llvm-cov] Add error for invalid -path-equivalence format

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 18:35:36 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe972e49b1109: [llvm-cov] Add error for invalid -path-equivalence format (authored by keith).

Changed prior to commit:
  https://reviews.llvm.org/D109042?vs=369847&id=372045#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109042/new/

https://reviews.llvm.org/D109042

Files:
  llvm/test/tools/llvm-cov/path_equivalence.c
  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
@@ -784,10 +784,18 @@
 
     // If path-equivalence was given and is a comma seperated pair then set
     // PathRemapping.
-    auto EquivPair = StringRef(PathRemap).split(',');
-    if (!(EquivPair.first.empty() && EquivPair.second.empty()))
+    if (!PathRemap.empty()) {
+      auto EquivPair = StringRef(PathRemap).split(',');
+      if (EquivPair.first.empty() || EquivPair.second.empty()) {
+        error("invalid argument '" + PathRemap +
+                  "', must be in format 'from,to'",
+              "-path-equivalence");
+        return 1;
+      }
+
       PathRemapping = {std::string(EquivPair.first),
                        std::string(EquivPair.second)};
+    }
 
     // If a demangler is supplied, check if it exists and register it.
     if (!DemanglerOpts.empty()) {
Index: llvm/test/tools/llvm-cov/path_equivalence.c
===================================================================
--- llvm/test/tools/llvm-cov/path_equivalence.c
+++ llvm/test/tools/llvm-cov/path_equivalence.c
@@ -2,3 +2,6 @@
 // RUN: llvm-cov show %S/Inputs/path_equivalence.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp,%S | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/path_equivalence.covmapping -instr-profile=%t.profdata -path-equivalence=/tmp/,%S/ | FileCheck %s
 int main() {} // CHECK: [[@LINE]]|      1|int main() {}
+
+// RUN: not llvm-cov show --instr-profile=/dev/null -path-equivalence=foo /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID: error: -path-equivalence: invalid argument 'foo', must be in format 'from,to'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109042.372045.patch
Type: text/x-patch
Size: 1757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210911/3de6ed81/attachment.bin>


More information about the llvm-commits mailing list