Skip to content

Commit dc058a3

Browse files
[TableGen] Use ListSeparator (NFC) (#144936)
Note that an instance of ListSeparator evaluates to the empty string for the first time and then ", " for subsequent references.
1 parent 28808dd commit dc058a3

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,14 +5482,12 @@ void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
54825482
}
54835483
const Record *SubjectObj = I.second->getValueAsDef("Subjects");
54845484
OS << " (";
5485-
bool PrintComma = false;
5485+
ListSeparator LS;
54865486
for (const auto &Subject :
54875487
enumerate(SubjectObj->getValueAsListOfDefs("Subjects"))) {
54885488
if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
54895489
continue;
5490-
if (PrintComma)
5491-
OS << ", ";
5492-
PrintComma = true;
5490+
OS << LS;
54935491
PragmaClangAttributeSupport::RuleOrAggregateRuleSet &RuleSet =
54945492
Support.SubjectsToRules.find(Subject.value())->getSecond();
54955493
if (RuleSet.isRule()) {

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,13 +2225,10 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
22252225
else
22262226
OS << "Also controls ";
22272227

2228-
bool First = true;
22292228
sort(GroupInfo.SubGroups);
2230-
for (StringRef Name : GroupInfo.SubGroups) {
2231-
if (!First) OS << ", ";
2232-
OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
2233-
First = false;
2234-
}
2229+
ListSeparator LS;
2230+
for (StringRef Name : GroupInfo.SubGroups)
2231+
OS << LS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
22352232
OS << ".\n\n";
22362233
}
22372234

0 commit comments

Comments
 (0)