[llvm] 6bfb02c - [TableGen] Use ListSeparator (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 31 10:24:12 PST 2021


Author: Kazu Hirata
Date: 2021-01-31T10:23:41-08:00
New Revision: 6bfb02cafe4fb31fd0a4f8a9871180df3333bd49

URL: https://github.com/llvm/llvm-project/commit/6bfb02cafe4fb31fd0a4f8a9871180df3333bd49
DIFF: https://github.com/llvm/llvm-project/commit/6bfb02cafe4fb31fd0a4f8a9871180df3333bd49.diff

LOG: [TableGen] Use ListSeparator (NFC)

Added: 
    

Modified: 
    llvm/utils/TableGen/SearchableTableEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 912d43b2caa1..b2633a0cf97b 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -414,13 +414,9 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
   }
   OS << "  };\n";
   OS << "  KeyType Key = {";
-  bool NeedComma = false;
+  ListSeparator LS;
   for (const auto &Field : Index.Fields) {
-    if (NeedComma)
-      OS << ", ";
-    NeedComma = true;
-
-    OS << Field.Name;
+    OS << LS << Field.Name;
     if (isa<StringRecTy>(Field.RecType)) {
       OS << ".upper()";
       if (IsPrimary)
@@ -482,15 +478,10 @@ void SearchableTableEmitter::emitLookupDeclaration(const GenericTable &Table,
                                                    raw_ostream &OS) {
   OS << "const " << Table.CppTypeName << " *" << Index.Name << "(";
 
-  bool NeedComma = false;
-  for (const auto &Field : Index.Fields) {
-    if (NeedComma)
-      OS << ", ";
-    NeedComma = true;
-
-    OS << searchableFieldType(Table, Index, Field, TypeInArgument) << " "
+  ListSeparator LS;
+  for (const auto &Field : Index.Fields)
+    OS << LS << searchableFieldType(Table, Index, Field, TypeInArgument) << " "
        << Field.Name;
-  }
   OS << ")";
 }
 


        


More information about the llvm-commits mailing list