mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[StringExtras] Rename SubsequentDelim to ListSeparator
This patch renames SubsequentDelim to ListSeparator to clarify the purpose of the class. Differential Revision: https://reviews.llvm.org/D94649
This commit is contained in:
parent
7b3a3516a0
commit
bebae30b36
@ -470,22 +470,22 @@ inline std::string join_items(Sep Separator, Args &&... Items) {
|
||||
/// list from a loop like so:
|
||||
///
|
||||
/// \code
|
||||
/// SubsequentDelim SD;
|
||||
/// ListSeparator SD;
|
||||
/// for (auto &I : C)
|
||||
/// OS << SD << I.getName();
|
||||
/// \end
|
||||
class SubsequentDelim {
|
||||
class ListSeparator {
|
||||
bool First = true;
|
||||
StringRef Delim;
|
||||
StringRef Separator;
|
||||
|
||||
public:
|
||||
SubsequentDelim(StringRef Delim = ", ") : Delim(Delim) {}
|
||||
public:
|
||||
ListSeparator(StringRef Separator = ", ") : Separator(Separator) {}
|
||||
operator StringRef() {
|
||||
if (First) {
|
||||
First = false;
|
||||
return {};
|
||||
}
|
||||
return Delim;
|
||||
return Separator;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -353,9 +353,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
|
||||
if (Indexes) OS << '\t';
|
||||
// Don't indent(2), align with previous line attributes.
|
||||
OS << "; predecessors: ";
|
||||
SubsequentDelim SD;
|
||||
ListSeparator LS;
|
||||
for (auto *Pred : predecessors())
|
||||
OS << SD << printMBBReference(*Pred);
|
||||
OS << LS << printMBBReference(*Pred);
|
||||
OS << '\n';
|
||||
HasLineAttributes = true;
|
||||
}
|
||||
@ -364,9 +364,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
|
||||
if (Indexes) OS << '\t';
|
||||
// Print the successors
|
||||
OS.indent(2) << "successors: ";
|
||||
SubsequentDelim SD;
|
||||
ListSeparator LS;
|
||||
for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
|
||||
OS << SD << printMBBReference(**I);
|
||||
OS << LS << printMBBReference(**I);
|
||||
if (!Probs.empty())
|
||||
OS << '('
|
||||
<< format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
|
||||
@ -375,10 +375,10 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
|
||||
if (!Probs.empty() && IsStandalone) {
|
||||
// Print human readable probabilities as comments.
|
||||
OS << "; ";
|
||||
SubsequentDelim SD;
|
||||
ListSeparator LS;
|
||||
for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
|
||||
const BranchProbability &BP = getSuccProbability(I);
|
||||
OS << SD << printMBBReference(**I) << '('
|
||||
OS << LS << printMBBReference(**I) << '('
|
||||
<< format("%.2f%%",
|
||||
rint(((double)BP.getNumerator() / BP.getDenominator()) *
|
||||
100.0 * 100.0) /
|
||||
@ -395,9 +395,9 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST,
|
||||
if (Indexes) OS << '\t';
|
||||
OS.indent(2) << "liveins: ";
|
||||
|
||||
SubsequentDelim SD;
|
||||
ListSeparator LS;
|
||||
for (const auto &LI : liveins()) {
|
||||
OS << SD << printReg(LI.PhysReg, TRI);
|
||||
OS << LS << printReg(LI.PhysReg, TRI);
|
||||
if (!LI.LaneMask.all())
|
||||
OS << ":0x" << PrintLaneMask(LI.LaneMask);
|
||||
}
|
||||
|
@ -216,16 +216,16 @@ TEST(StringExtras, IToStr) {
|
||||
EXPECT_EQ(std::to_string(MaxInt64), itostr(MaxInt64));
|
||||
}
|
||||
|
||||
TEST(StringExtras, SubsequentDelim) {
|
||||
SubsequentDelim SD;
|
||||
StringRef S = SD;
|
||||
TEST(StringExtras, ListSeparator) {
|
||||
ListSeparator LS;
|
||||
StringRef S = LS;
|
||||
EXPECT_EQ(S, "");
|
||||
S = SD;
|
||||
S = LS;
|
||||
EXPECT_EQ(S, ", ");
|
||||
|
||||
SubsequentDelim SD2(" ");
|
||||
S = SD2;
|
||||
ListSeparator LS2(" ");
|
||||
S = LS2;
|
||||
EXPECT_EQ(S, "");
|
||||
S = SD2;
|
||||
S = LS2;
|
||||
EXPECT_EQ(S, " ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user