-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[llvm] Use llvm::interleaved (NFC) #145839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm] Use llvm::interleaved (NFC) #145839
Conversation
Note that llvm::interleaved constructs a string with the elements from a given range with a given separator.
@llvm/pr-subscribers-tools-llvm-exegesis @llvm/pr-subscribers-debuginfo Author: Kazu Hirata (kazutakahirata) ChangesNote that llvm::interleaved constructs a string with the elements from Full diff: https://github.com/llvm/llvm-project/pull/145839.diff 3 Files Affected:
diff --git a/llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp b/llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp
index 8cd4e22d34fcf..4af8d3044f4de 100644
--- a/llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp
+++ b/llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp
@@ -12,6 +12,7 @@
#include "llvm/DebugInfo/GSYM/GsymCreator.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
@@ -231,13 +232,7 @@ Error CallSiteInfoLoader::processYAMLFunctions(
raw_ostream &gsym::operator<<(raw_ostream &OS, const CallSiteInfo &CSI) {
OS << " Return=" << HEX64(CSI.ReturnOffset);
OS << " Flags=" << HEX8(CSI.Flags);
-
- OS << " RegEx=";
- for (uint32_t i = 0; i < CSI.MatchRegex.size(); ++i) {
- if (i > 0)
- OS << ",";
- OS << CSI.MatchRegex[i];
- }
+ OS << " RegEx=" << llvm::interleaved(CSI.MatchRegex, ",");
return OS;
}
diff --git a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
index e0e796cee8040..66c770d9ca86b 100644
--- a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
+++ b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
@@ -12,6 +12,7 @@
#include <tuple>
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/InterleavedRange.h"
namespace llvm {
namespace exegesis {
@@ -293,15 +294,8 @@ void Instruction::dump(const MCRegisterInfo &RegInfo,
}
for (const auto &Var : Variables) {
Stream << "- Var" << Var.getIndex();
- Stream << " [";
- bool IsFirst = true;
- for (auto OperandIndex : Var.TiedOperands) {
- if (!IsFirst)
- Stream << ",";
- Stream << "Op" << OperandIndex;
- IsFirst = false;
- }
- Stream << "]";
+ Stream << " ";
+ Stream << llvm::interleaved_array(Var.TiedOperands, ",");
Stream << "\n";
}
if (hasMemoryOperands())
diff --git a/llvm/tools/llvm-remarkutil/RemarkCounter.cpp b/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
index 0e6198cbb5203..7d5c84815b3bb 100644
--- a/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
+++ b/llvm/tools/llvm-remarkutil/RemarkCounter.cpp
@@ -13,6 +13,7 @@
#include "RemarkCounter.h"
#include "RemarkUtilRegistry.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/Regex.h"
using namespace llvm;
@@ -197,23 +198,11 @@ Error ArgumentCounter::print(StringRef OutputFileName) {
auto OF = std::move(*MaybeOF);
OF->os() << groupByToStr(Group) << ",";
- unsigned Idx = 0;
- for (auto [Key, _] : ArgumentSetIdxMap) {
- OF->os() << Key;
- if (Idx != ArgumentSetIdxMap.size() - 1)
- OF->os() << ",";
- Idx++;
- }
+ OF->os() << llvm::interleaved(llvm::make_first_range(ArgumentSetIdxMap), ",");
OF->os() << "\n";
for (auto [Header, CountVector] : CountByKeysMap) {
OF->os() << Header << ",";
- unsigned Idx = 0;
- for (auto Count : CountVector) {
- OF->os() << Count;
- if (Idx != ArgumentSetIdxMap.size() - 1)
- OF->os() << ",";
- Idx++;
- }
+ OF->os() << llvm::interleaved(CountVector, ",");
OF->os() << "\n";
}
return Error::success();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers!
Note that llvm::interleaved constructs a string with the elements from a given range with a given separator.
Note that llvm::interleaved constructs a string with the elements from a given range with a given separator.
Note that llvm::interleaved constructs a string with the elements from
a given range with a given separator.