Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.
This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.
This doesn't actually modify StringRef yet, I'll do that in a follow-up.
diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp
index 1e3ec30..713b419 100644
--- a/llvm/lib/Support/DebugCounter.cpp
+++ b/llvm/lib/Support/DebugCounter.cpp
@@ -85,7 +85,7 @@
// add it to the counter values.
if (CounterPair.first.endswith("-skip")) {
auto CounterName = CounterPair.first.drop_back(5);
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
if (!CounterID) {
errs() << "DebugCounter Error: " << CounterName
<< " is not a registered counter\n";
@@ -98,7 +98,7 @@
Counter.IsSet = true;
} else if (CounterPair.first.endswith("-count")) {
auto CounterName = CounterPair.first.drop_back(6);
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
if (!CounterID) {
errs() << "DebugCounter Error: " << CounterName
<< " is not a registered counter\n";
@@ -123,7 +123,7 @@
auto &Us = instance();
OS << "Counters and values:\n";
for (auto &CounterName : CounterNames) {
- unsigned CounterID = getCounterId(CounterName);
+ unsigned CounterID = getCounterId(std::string(CounterName));
OS << left_justify(RegisteredCounters[CounterID], 32) << ": {"
<< Us.Counters[CounterID].Count << "," << Us.Counters[CounterID].Skip
<< "," << Us.Counters[CounterID].StopAfter << "}\n";