[PATCH] D109042: [llvm-cov] Add error for invalid -path-equivalence format
Keith Smiley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 31 22:36:15 PDT 2021
keith created this revision.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
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.369847.patch
Type: text/x-patch
Size: 1740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210901/acdb8a76/attachment.bin>
More information about the llvm-commits
mailing list