Skip to content

Commit 89b3de6

Browse files
[llvm] Use llvm::interleaved (NFC) (#137531)
1 parent 1f56716 commit 89b3de6

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,7 @@ struct MIBInfo {
378378

379379
inline raw_ostream &operator<<(raw_ostream &OS, const MIBInfo &MIB) {
380380
OS << "AllocType " << (unsigned)MIB.AllocType;
381-
bool First = true;
382-
OS << " StackIds: ";
383-
for (auto Id : MIB.StackIdIndices) {
384-
if (!First)
385-
OS << ", ";
386-
First = false;
387-
OS << Id;
388-
}
381+
OS << " StackIds: " << llvm::interleaved(MIB.StackIdIndices);
389382
return OS;
390383
}
391384

llvm/utils/TableGen/OptionParserEmitter.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "llvm/ADT/SmallString.h"
1212
#include "llvm/ADT/StringExtras.h"
1313
#include "llvm/ADT/Twine.h"
14+
#include "llvm/Support/InterleavedRange.h"
1415
#include "llvm/Support/raw_ostream.h"
1516
#include "llvm/TableGen/Record.h"
1617
#include "llvm/TableGen/StringToOffsetTable.h"
@@ -232,17 +233,8 @@ static void emitHelpTextsForVariants(
232233
assert(Visibilities.size() <= MaxVisibilityPerHelp &&
233234
"Too many visibilities to store in an "
234235
"OptTable::HelpTextsForVariants entry");
235-
OS << "{std::array<unsigned, " << MaxVisibilityPerHelp << ">{{";
236-
237-
auto VisibilityEnd = Visibilities.cend();
238-
for (auto Visibility = Visibilities.cbegin(); Visibility != VisibilityEnd;
239-
++Visibility) {
240-
OS << *Visibility;
241-
if (std::next(Visibility) != VisibilityEnd)
242-
OS << ", ";
243-
}
244-
245-
OS << "}}, ";
236+
OS << "{std::array<unsigned, " << MaxVisibilityPerHelp << ">{{"
237+
<< llvm::interleaved(Visibilities) << "}}, ";
246238

247239
if (Help.size())
248240
writeCstring(OS, Help);

0 commit comments

Comments
 (0)