@@ -387,18 +387,6 @@ static std::vector<Spelling::Value>
387387orderSpellings (ArrayRef<Spelling::Value> Spellings) {
388388 std::vector<Spelling::Value> List (Spellings.begin (), Spellings.end ());
389389
390- // There are two intertwined orderings: (1) the order between spellings
391- // (used here), and (2) the order between a spelling and a version (used
392- // at runtime).
393- // Define order (2) as such that the first A that is not less than V
394- // will be the selected spelling given V. Specifically,
395- // V <(2) A <=> V < A.Min
396- // A <(2) V <=> A.Max < V
397- //
398- // The orders have to be compatible, i.e.
399- // A <(2) V and !(V <(2) B) => A <(1) B, and
400- // !(A <(2) v) and V <(2) B => A <(1) B
401- // In other words, the transitive closure of (2) must contain (1).
402390 llvm::stable_sort (List,
403391 [](const Spelling::Value &A, const Spelling::Value &B) {
404392 return A.Versions < B.Versions ;
@@ -421,16 +409,16 @@ static void generateGetName(ArrayRef<const Record *> Records, raw_ostream &OS,
421409 BaseRecord Rec (R);
422410 std::string Ident = getIdentifierName (R, Prefix);
423411 OS << " case " << Ident << " :" ;
424- auto Spellings (orderSpellings (Rec.getSpellings ()));
412+ std::vector<Spelling::Value> Spellings (orderSpellings (Rec.getSpellings ()));
425413 assert (Spellings.size () != 0 && " No spellings for this item" );
426414 if (Spellings.size () == 1 ) {
427415 OS << " \n " ;
428416 OS << " return \" " << Spellings.front ().Name << " \" ;\n " ;
429417 } else {
430418 OS << " {\n " ;
431419 std::string SpellingsName = Ident + " _spellings" ;
432- OS << " static const llvm::directive::Spelling " << SpellingsName
433- << " [] = {\n " ;
420+ OS << " static constexpr llvm::directive::Spelling "
421+ << SpellingsName << " [] = {\n " ;
434422 for (auto &S : Spellings) {
435423 OS << " {\" " << S.Name << " \" , {" << S.Versions .Min << " , "
436424 << S.Versions .Max << " }},\n " ;
@@ -484,11 +472,10 @@ static void generateGetKind(ArrayRef<const Record *> Records, raw_ostream &OS,
484472
485473 for (auto &[Name, Versions] : Rec.getSpellings ()) {
486474 OS << " .Case(\" " << Name << " \" , {" << Ident << " , " ;
487- if (Versions.Min == All.Min && Versions.Max == All.Max ) {
475+ if (Versions.Min == All.Min && Versions.Max == All.Max )
488476 OS << " All})\n " ;
489- } else {
477+ else
490478 OS << " {" << Versions.Min << " , " << Versions.Max << " }})\n " ;
491- }
492479 }
493480 }
494481 OS << " .Default({" << DefaultName << " , All});\n " ;
0 commit comments