[llvm] f0d5898 - [Support] Use ListSeparator (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 15 14:47:16 PST 2021
Author: Kazu Hirata
Date: 2021-02-15T14:46:09-08:00
New Revision: f0d5898f939fe81e1a3e3e74cb8f04b9028f7e6b
URL: https://github.com/llvm/llvm-project/commit/f0d5898f939fe81e1a3e3e74cb8f04b9028f7e6b
DIFF: https://github.com/llvm/llvm-project/commit/f0d5898f939fe81e1a3e3e74cb8f04b9028f7e6b.diff
LOG: [Support] Use ListSeparator (NFC)
Added:
Modified:
llvm/include/llvm/Support/ScopedPrinter.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index c5e5386ce21d..fe800e324047 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -12,6 +12,7 @@
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/Endian.h"
@@ -207,38 +208,28 @@ class ScopedPrinter {
template <typename T> void printList(StringRef Label, const T &List) {
startLine() << Label << ": [";
- bool Comma = false;
- for (const auto &Item : List) {
- if (Comma)
- OS << ", ";
- OS << Item;
- Comma = true;
- }
+ ListSeparator LS;
+ for (const auto &Item : List)
+ OS << LS << Item;
OS << "]\n";
}
template <typename T, typename U>
void printList(StringRef Label, const T &List, const U &Printer) {
startLine() << Label << ": [";
- bool Comma = false;
+ ListSeparator LS;
for (const auto &Item : List) {
- if (Comma)
- OS << ", ";
+ OS << LS;
Printer(OS, Item);
- Comma = true;
}
OS << "]\n";
}
template <typename T> void printHexList(StringRef Label, const T &List) {
startLine() << Label << ": [";
- bool Comma = false;
- for (const auto &Item : List) {
- if (Comma)
- OS << ", ";
- OS << hex(Item);
- Comma = true;
- }
+ ListSeparator LS;
+ for (const auto &Item : List)
+ OS << LS << hex(Item);
OS << "]\n";
}
More information about the llvm-commits
mailing list