@@ -46,8 +46,8 @@ class IfDefScope {
4646
4747// Generate enum class. Entries are emitted in the order in which they appear
4848// in the `Records` vector.
49- static void GenerateEnumClass (const std::vector< Record *> & Records,
50- raw_ostream &OS, StringRef Enum, StringRef Prefix,
49+ static void GenerateEnumClass (ArrayRef< const Record *> Records, raw_ostream &OS ,
50+ StringRef Enum, StringRef Prefix,
5151 const DirectiveLanguage &DirLang,
5252 bool ExportEnums) {
5353 OS << " \n " ;
@@ -79,7 +79,7 @@ static void GenerateEnumClass(const std::vector<Record *> &Records,
7979
8080// Generate enums for values that clauses can take.
8181// Also generate function declarations for get<Enum>Name(StringRef Str).
82- static void GenerateEnumClauseVal (const std::vector< Record *> & Records,
82+ static void GenerateEnumClauseVal (ArrayRef< const Record *> Records,
8383 raw_ostream &OS,
8484 const DirectiveLanguage &DirLang,
8585 std::string &EnumHelperFuncs) {
@@ -144,7 +144,7 @@ static bool HasDuplicateClauses(const std::vector<Record *> &Clauses,
144144// three allowed list. Also, since required implies allowed, clauses cannot
145145// appear in both the allowedClauses and requiredClauses lists.
146146static bool
147- HasDuplicateClausesInDirectives (const std::vector< Record *> & Directives) {
147+ HasDuplicateClausesInDirectives (ArrayRef< const Record *> Directives) {
148148 bool HasDuplicate = false ;
149149 for (const auto &D : Directives) {
150150 Directive Dir{D};
@@ -184,7 +184,7 @@ bool DirectiveLanguage::HasValidityErrors() const {
184184// Count the maximum number of leaf constituents per construct.
185185static size_t GetMaxLeafCount (const DirectiveLanguage &DirLang) {
186186 size_t MaxCount = 0 ;
187- for (Record *R : DirLang.getDirectives ()) {
187+ for (const Record *R : DirLang.getDirectives ()) {
188188 size_t Count = Directive{R}.getLeafConstructs ().size ();
189189 MaxCount = std::max (MaxCount, Count);
190190 }
@@ -193,7 +193,7 @@ static size_t GetMaxLeafCount(const DirectiveLanguage &DirLang) {
193193
194194// Generate the declaration section for the enumeration in the directive
195195// language
196- static void EmitDirectivesDecl (RecordKeeper &Records, raw_ostream &OS) {
196+ static void EmitDirectivesDecl (const RecordKeeper &Records, raw_ostream &OS) {
197197 const auto DirLang = DirectiveLanguage{Records};
198198 if (DirLang.HasValidityErrors ())
199199 return ;
@@ -220,7 +220,7 @@ static void EmitDirectivesDecl(RecordKeeper &Records, raw_ostream &OS) {
220220 OS << " \n LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();\n " ;
221221
222222 // Emit Directive associations
223- std::vector<Record *> associations;
223+ std::vector<const Record *> associations;
224224 llvm::copy_if (
225225 DirLang.getAssociations (), std::back_inserter (associations),
226226 // Skip the "special" value
@@ -283,9 +283,8 @@ static void EmitDirectivesDecl(RecordKeeper &Records, raw_ostream &OS) {
283283}
284284
285285// Generate function implementation for get<Enum>Name(StringRef Str)
286- static void GenerateGetName (const std::vector<Record *> &Records,
287- raw_ostream &OS, StringRef Enum,
288- const DirectiveLanguage &DirLang,
286+ static void GenerateGetName (ArrayRef<const Record *> Records, raw_ostream &OS,
287+ StringRef Enum, const DirectiveLanguage &DirLang,
289288 StringRef Prefix) {
290289 OS << " \n " ;
291290 OS << " llvm::StringRef llvm::" << DirLang.getCppNamespace () << " ::get"
@@ -308,13 +307,13 @@ static void GenerateGetName(const std::vector<Record *> &Records,
308307}
309308
310309// Generate function implementation for get<Enum>Kind(StringRef Str)
311- static void GenerateGetKind (const std::vector<Record *> &Records,
312- raw_ostream &OS, StringRef Enum,
313- const DirectiveLanguage &DirLang, StringRef Prefix,
314- bool ImplicitAsUnknown) {
310+ static void GenerateGetKind (ArrayRef<const Record *> Records, raw_ostream &OS,
311+ StringRef Enum, const DirectiveLanguage &DirLang,
312+ StringRef Prefix, bool ImplicitAsUnknown) {
315313
316- auto DefaultIt = llvm::find_if (
317- Records, [](Record *R) { return R->getValueAsBit (" isDefault" ) == true ; });
314+ auto DefaultIt = llvm::find_if (Records, [](const Record *R) {
315+ return R->getValueAsBit (" isDefault" ) == true ;
316+ });
318317
319318 if (DefaultIt == Records.end ()) {
320319 PrintError (" At least one " + Enum + " must be defined as default." );
@@ -506,8 +505,8 @@ static void EmitLeafTable(const DirectiveLanguage &DirLang, raw_ostream &OS,
506505 // row. To avoid this, an auxiliary ordering table is created, such that
507506 // row for Dir_A = table[auxiliary[Dir_A]].
508507
509- std::vector< Record *> Directives = DirLang.getDirectives ();
510- DenseMap<Record *, int > DirId; // Record * -> llvm::omp::Directive
508+ ArrayRef< const Record *> Directives = DirLang.getDirectives ();
509+ DenseMap<const Record *, int > DirId; // Record * -> llvm::omp::Directive
511510
512511 for (auto [Idx, Rec] : llvm::enumerate (Directives))
513512 DirId.insert (std::make_pair (Rec, Idx));
@@ -628,7 +627,7 @@ static void GenerateGetDirectiveAssociation(const DirectiveLanguage &DirLang,
628627 Invalid,
629628 };
630629
631- std::vector< Record *> associations = DirLang.getAssociations ();
630+ ArrayRef< const Record *> associations = DirLang.getAssociations ();
632631
633632 auto getAssocValue = [](StringRef name) -> Association {
634633 return StringSwitch<Association>(name)
@@ -720,7 +719,7 @@ static void GenerateGetDirectiveAssociation(const DirectiveLanguage &DirLang,
720719 return Result;
721720 };
722721
723- for (Record *R : DirLang.getDirectives ())
722+ for (const Record *R : DirLang.getDirectives ())
724723 compAssocImpl (R, compAssocImpl); // Updates AsMap.
725724
726725 OS << ' \n ' ;
@@ -739,7 +738,7 @@ static void GenerateGetDirectiveAssociation(const DirectiveLanguage &DirLang,
739738 OS << AssociationTypeName << " llvm::" << DirLang.getCppNamespace ()
740739 << " ::getDirectiveAssociation(" << DirectiveTypeName << " Dir) {\n " ;
741740 OS << " switch (Dir) {\n " ;
742- for (Record *R : DirLang.getDirectives ()) {
741+ for (const Record *R : DirLang.getDirectives ()) {
743742 if (auto F = AsMap.find (R); F != AsMap.end ()) {
744743 Directive Dir{R};
745744 OS << " case " << getQualifiedName (Dir.getFormattedName ()) << " :\n " ;
@@ -763,7 +762,7 @@ static void GenerateGetDirectiveCategory(const DirectiveLanguage &DirLang,
763762 << GetDirectiveType (DirLang) << " Dir) {\n " ;
764763 OS << " switch (Dir) {\n " ;
765764
766- for (Record *R : DirLang.getDirectives ()) {
765+ for (const Record *R : DirLang.getDirectives ()) {
767766 Directive D{R};
768767 OS << " case " << GetDirectiveName (DirLang, R) << " :\n " ;
769768 OS << " return " << CategoryNamespace
@@ -903,7 +902,7 @@ static void GenerateFlangClauseParserClassList(const DirectiveLanguage &DirLang,
903902 IfDefScope Scope (" GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST" , OS);
904903
905904 OS << " \n " ;
906- llvm::interleaveComma (DirLang.getClauses (), OS, [&](Record *C) {
905+ llvm::interleaveComma (DirLang.getClauses (), OS, [&](const Record *C) {
907906 Clause Clause{C};
908907 OS << Clause.getFormattedParserClassName () << " \n " ;
909908 });
@@ -1013,7 +1012,7 @@ static void GenerateFlangClauseParserKindMap(const DirectiveLanguage &DirLang,
10131012 << " Parser clause\" );\n " ;
10141013}
10151014
1016- static bool compareClauseName (Record *R1, Record *R2) {
1015+ static bool compareClauseName (const Record *R1, const Record *R2) {
10171016 Clause C1{R1};
10181017 Clause C2{R2};
10191018 return (C1.getName () > C2.getName ());
@@ -1022,7 +1021,7 @@ static bool compareClauseName(Record *R1, Record *R2) {
10221021// Generate the parser for the clauses.
10231022static void GenerateFlangClausesParser (const DirectiveLanguage &DirLang,
10241023 raw_ostream &OS) {
1025- std::vector<Record *> Clauses = DirLang.getClauses ();
1024+ std::vector<const Record *> Clauses = DirLang.getClauses ();
10261025 // Sort clauses in reverse alphabetical order so with clauses with same
10271026 // beginning, the longer option is tried before.
10281027 llvm::sort (Clauses, compareClauseName);
@@ -1231,7 +1230,7 @@ void EmitDirectivesBasicImpl(const DirectiveLanguage &DirLang,
12311230
12321231// Generate the implemenation section for the enumeration in the directive
12331232// language.
1234- static void EmitDirectivesImpl (RecordKeeper &Records, raw_ostream &OS) {
1233+ static void EmitDirectivesImpl (const RecordKeeper &Records, raw_ostream &OS) {
12351234 const auto DirLang = DirectiveLanguage{Records};
12361235 if (DirLang.HasValidityErrors ())
12371236 return ;
0 commit comments