@@ -37,11 +37,12 @@ class IfDefScope {
37
37
StringRef Name;
38
38
raw_ostream &OS;
39
39
};
40
+ } // namespace
40
41
41
42
// Generate enum class
42
- void GenerateEnumClass (const std::vector<Record *> &Records, raw_ostream &OS ,
43
- StringRef Enum, StringRef Prefix,
44
- const DirectiveLanguage &DirLang) {
43
+ static void GenerateEnumClass (const std::vector<Record *> &Records,
44
+ raw_ostream &OS, StringRef Enum, StringRef Prefix,
45
+ const DirectiveLanguage &DirLang) {
45
46
OS << " \n " ;
46
47
OS << " enum class " << Enum << " {\n " ;
47
48
for (const auto &R : Records) {
@@ -71,9 +72,10 @@ void GenerateEnumClass(const std::vector<Record *> &Records, raw_ostream &OS,
71
72
72
73
// Generate enums for values that clauses can take.
73
74
// Also generate function declarations for get<Enum>Name(StringRef Str).
74
- void GenerateEnumClauseVal (const std::vector<Record *> &Records,
75
- raw_ostream &OS, const DirectiveLanguage &DirLang,
76
- std::string &EnumHelperFuncs) {
75
+ static void GenerateEnumClauseVal (const std::vector<Record *> &Records,
76
+ raw_ostream &OS,
77
+ const DirectiveLanguage &DirLang,
78
+ std::string &EnumHelperFuncs) {
77
79
for (const auto &R : Records) {
78
80
Clause C{R};
79
81
const auto &ClauseVals = C.getClauseVals ();
@@ -115,9 +117,9 @@ void GenerateEnumClauseVal(const std::vector<Record *> &Records,
115
117
}
116
118
}
117
119
118
- bool HasDuplicateClauses (const std::vector<Record *> &Clauses,
119
- const Directive &Directive,
120
- llvm::StringSet<> &CrtClauses) {
120
+ static bool HasDuplicateClauses (const std::vector<Record *> &Clauses,
121
+ const Directive &Directive,
122
+ llvm::StringSet<> &CrtClauses) {
121
123
bool HasError = false ;
122
124
for (const auto &C : Clauses) {
123
125
VersionedClause VerClause{C};
@@ -134,7 +136,8 @@ bool HasDuplicateClauses(const std::vector<Record *> &Clauses,
134
136
// Check for duplicate clauses in lists. Clauses cannot appear twice in the
135
137
// three allowed list. Also, since required implies allowed, clauses cannot
136
138
// appear in both the allowedClauses and requiredClauses lists.
137
- bool HasDuplicateClausesInDirectives (const std::vector<Record *> &Directives) {
139
+ static bool
140
+ HasDuplicateClausesInDirectives (const std::vector<Record *> &Directives) {
138
141
bool HasDuplicate = false ;
139
142
for (const auto &D : Directives) {
140
143
Directive Dir{D};
@@ -160,8 +163,6 @@ bool HasDuplicateClausesInDirectives(const std::vector<Record *> &Directives) {
160
163
return HasDuplicate;
161
164
}
162
165
163
- } // namespace
164
-
165
166
// Check consitency of records. Return true if an error has been detected.
166
167
// Return false if the records are valid.
167
168
bool DirectiveLanguage::HasValidityErrors () const {
@@ -248,12 +249,11 @@ void EmitDirectivesDecl(RecordKeeper &Records, raw_ostream &OS) {
248
249
249
250
} // namespace llvm
250
251
251
- namespace {
252
-
253
252
// Generate function implementation for get<Enum>Name(StringRef Str)
254
- void GenerateGetName (const std::vector<Record *> &Records, raw_ostream &OS,
255
- StringRef Enum, const DirectiveLanguage &DirLang,
256
- StringRef Prefix) {
253
+ static void GenerateGetName (const std::vector<Record *> &Records,
254
+ raw_ostream &OS, StringRef Enum,
255
+ const DirectiveLanguage &DirLang,
256
+ StringRef Prefix) {
257
257
OS << " \n " ;
258
258
OS << " llvm::StringRef llvm::" << DirLang.getCppNamespace () << " ::get"
259
259
<< DirLang.getName () << Enum << " Name(" << Enum << " Kind) {\n " ;
@@ -275,9 +275,10 @@ void GenerateGetName(const std::vector<Record *> &Records, raw_ostream &OS,
275
275
}
276
276
277
277
// Generate function implementation for get<Enum>Kind(StringRef Str)
278
- void GenerateGetKind (const std::vector<Record *> &Records, raw_ostream &OS,
279
- StringRef Enum, const DirectiveLanguage &DirLang,
280
- StringRef Prefix, bool ImplicitAsUnknown) {
278
+ static void GenerateGetKind (const std::vector<Record *> &Records,
279
+ raw_ostream &OS, StringRef Enum,
280
+ const DirectiveLanguage &DirLang, StringRef Prefix,
281
+ bool ImplicitAsUnknown) {
281
282
282
283
auto DefaultIt = llvm::find_if (
283
284
Records, [](Record *R) { return R->getValueAsBit (" isDefault" ) == true ; });
@@ -309,8 +310,8 @@ void GenerateGetKind(const std::vector<Record *> &Records, raw_ostream &OS,
309
310
}
310
311
311
312
// Generate function implementation for get<ClauseVal>Kind(StringRef Str)
312
- void GenerateGetKindClauseVal (const DirectiveLanguage &DirLang,
313
- raw_ostream &OS) {
313
+ static void GenerateGetKindClauseVal (const DirectiveLanguage &DirLang,
314
+ raw_ostream &OS) {
314
315
for (const auto &R : DirLang.getClauses ()) {
315
316
Clause C{R};
316
317
const auto &ClauseVals = C.getClauseVals ();
@@ -365,10 +366,11 @@ void GenerateGetKindClauseVal(const DirectiveLanguage &DirLang,
365
366
}
366
367
}
367
368
368
- void GenerateCaseForVersionedClauses (const std::vector<Record *> &Clauses,
369
- raw_ostream &OS, StringRef DirectiveName,
370
- const DirectiveLanguage &DirLang,
371
- llvm::StringSet<> &Cases) {
369
+ static void
370
+ GenerateCaseForVersionedClauses (const std::vector<Record *> &Clauses,
371
+ raw_ostream &OS, StringRef DirectiveName,
372
+ const DirectiveLanguage &DirLang,
373
+ llvm::StringSet<> &Cases) {
372
374
for (const auto &C : Clauses) {
373
375
VersionedClause VerClause{C};
374
376
@@ -384,8 +386,8 @@ void GenerateCaseForVersionedClauses(const std::vector<Record *> &Clauses,
384
386
}
385
387
386
388
// Generate the isAllowedClauseForDirective function implementation.
387
- void GenerateIsAllowedClause (const DirectiveLanguage &DirLang,
388
- raw_ostream &OS) {
389
+ static void GenerateIsAllowedClause (const DirectiveLanguage &DirLang,
390
+ raw_ostream &OS) {
389
391
OS << " \n " ;
390
392
OS << " bool llvm::" << DirLang.getCppNamespace ()
391
393
<< " ::isAllowedClauseForDirective("
@@ -438,9 +440,10 @@ void GenerateIsAllowedClause(const DirectiveLanguage &DirLang,
438
440
}
439
441
440
442
// Generate a simple enum set with the give clauses.
441
- void GenerateClauseSet (const std::vector<Record *> &Clauses, raw_ostream &OS,
442
- StringRef ClauseSetPrefix, Directive &Dir,
443
- const DirectiveLanguage &DirLang) {
443
+ static void GenerateClauseSet (const std::vector<Record *> &Clauses,
444
+ raw_ostream &OS, StringRef ClauseSetPrefix,
445
+ Directive &Dir,
446
+ const DirectiveLanguage &DirLang) {
444
447
445
448
OS << " \n " ;
446
449
OS << " static " << DirLang.getClauseEnumSetClass () << " " << ClauseSetPrefix
@@ -456,8 +459,8 @@ void GenerateClauseSet(const std::vector<Record *> &Clauses, raw_ostream &OS,
456
459
}
457
460
458
461
// Generate an enum set for the 4 kinds of clauses linked to a directive.
459
- void GenerateDirectiveClauseSets (const DirectiveLanguage &DirLang,
460
- raw_ostream &OS) {
462
+ static void GenerateDirectiveClauseSets (const DirectiveLanguage &DirLang,
463
+ raw_ostream &OS) {
461
464
462
465
IfDefScope Scope (" GEN_FLANG_DIRECTIVE_CLAUSE_SETS" , OS);
463
466
@@ -496,8 +499,8 @@ void GenerateDirectiveClauseSets(const DirectiveLanguage &DirLang,
496
499
// Generate a map of directive (key) with DirectiveClauses struct as values.
497
500
// The struct holds the 4 sets of enumeration for the 4 kinds of clauses
498
501
// allowances (allowed, allowed once, allowed exclusive and required).
499
- void GenerateDirectiveClauseMap (const DirectiveLanguage &DirLang,
500
- raw_ostream &OS) {
502
+ static void GenerateDirectiveClauseMap (const DirectiveLanguage &DirLang,
503
+ raw_ostream &OS) {
501
504
502
505
IfDefScope Scope (" GEN_FLANG_DIRECTIVE_CLAUSE_MAP" , OS);
503
506
@@ -531,8 +534,8 @@ void GenerateDirectiveClauseMap(const DirectiveLanguage &DirLang,
531
534
// If the clause does not hold a value, an EMPTY_CLASS is used.
532
535
// If the clause class is generic then a WRAPPER_CLASS is used. When the value
533
536
// is optional, the value class is wrapped into a std::optional.
534
- void GenerateFlangClauseParserClass (const DirectiveLanguage &DirLang,
535
- raw_ostream &OS) {
537
+ static void GenerateFlangClauseParserClass (const DirectiveLanguage &DirLang,
538
+ raw_ostream &OS) {
536
539
537
540
IfDefScope Scope (" GEN_FLANG_CLAUSE_PARSER_CLASSES" , OS);
538
541
@@ -559,8 +562,8 @@ void GenerateFlangClauseParserClass(const DirectiveLanguage &DirLang,
559
562
}
560
563
561
564
// Generate a list of the different clause classes for Flang.
562
- void GenerateFlangClauseParserClassList (const DirectiveLanguage &DirLang,
563
- raw_ostream &OS) {
565
+ static void GenerateFlangClauseParserClassList (const DirectiveLanguage &DirLang,
566
+ raw_ostream &OS) {
564
567
565
568
IfDefScope Scope (" GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST" , OS);
566
569
@@ -572,8 +575,8 @@ void GenerateFlangClauseParserClassList(const DirectiveLanguage &DirLang,
572
575
}
573
576
574
577
// Generate dump node list for the clauses holding a generic class name.
575
- void GenerateFlangClauseDump (const DirectiveLanguage &DirLang,
576
- raw_ostream &OS) {
578
+ static void GenerateFlangClauseDump (const DirectiveLanguage &DirLang,
579
+ raw_ostream &OS) {
577
580
578
581
IfDefScope Scope (" GEN_FLANG_DUMP_PARSE_TREE_CLAUSES" , OS);
579
582
@@ -587,8 +590,8 @@ void GenerateFlangClauseDump(const DirectiveLanguage &DirLang,
587
590
588
591
// Generate Unparse functions for clauses classes in the Flang parse-tree
589
592
// If the clause is a non-generic class, no entry is generated.
590
- void GenerateFlangClauseUnparse (const DirectiveLanguage &DirLang,
591
- raw_ostream &OS) {
593
+ static void GenerateFlangClauseUnparse (const DirectiveLanguage &DirLang,
594
+ raw_ostream &OS) {
592
595
593
596
IfDefScope Scope (" GEN_FLANG_CLAUSE_UNPARSE" , OS);
594
597
@@ -639,8 +642,8 @@ void GenerateFlangClauseUnparse(const DirectiveLanguage &DirLang,
639
642
}
640
643
641
644
// Generate check in the Enter functions for clauses classes.
642
- void GenerateFlangClauseCheckPrototypes (const DirectiveLanguage &DirLang,
643
- raw_ostream &OS) {
645
+ static void GenerateFlangClauseCheckPrototypes (const DirectiveLanguage &DirLang,
646
+ raw_ostream &OS) {
644
647
645
648
IfDefScope Scope (" GEN_FLANG_CLAUSE_CHECK_ENTER" , OS);
646
649
@@ -654,8 +657,8 @@ void GenerateFlangClauseCheckPrototypes(const DirectiveLanguage &DirLang,
654
657
655
658
// Generate the mapping for clauses between the parser class and the
656
659
// corresponding clause Kind
657
- void GenerateFlangClauseParserKindMap (const DirectiveLanguage &DirLang,
658
- raw_ostream &OS) {
660
+ static void GenerateFlangClauseParserKindMap (const DirectiveLanguage &DirLang,
661
+ raw_ostream &OS) {
659
662
660
663
IfDefScope Scope (" GEN_FLANG_CLAUSE_PARSER_KIND_MAP" , OS);
661
664
@@ -675,15 +678,15 @@ void GenerateFlangClauseParserKindMap(const DirectiveLanguage &DirLang,
675
678
<< " Parser clause\" );\n " ;
676
679
}
677
680
678
- bool compareClauseName (Record *R1, Record *R2) {
681
+ static bool compareClauseName (Record *R1, Record *R2) {
679
682
Clause C1{R1};
680
683
Clause C2{R2};
681
684
return (C1.getName () > C2.getName ());
682
685
}
683
686
684
687
// Generate the parser for the clauses.
685
- void GenerateFlangClausesParser (const DirectiveLanguage &DirLang,
686
- raw_ostream &OS) {
688
+ static void GenerateFlangClausesParser (const DirectiveLanguage &DirLang,
689
+ raw_ostream &OS) {
687
690
std::vector<Record *> Clauses = DirLang.getClauses ();
688
691
// Sort clauses in reverse alphabetical order so with clauses with same
689
692
// beginning, the longer option is tried before.
@@ -756,8 +759,8 @@ void GenerateFlangClausesParser(const DirectiveLanguage &DirLang,
756
759
757
760
// Generate the implementation section for the enumeration in the directive
758
761
// language
759
- void EmitDirectivesFlangImpl (const DirectiveLanguage &DirLang,
760
- raw_ostream &OS) {
762
+ static void EmitDirectivesFlangImpl (const DirectiveLanguage &DirLang,
763
+ raw_ostream &OS) {
761
764
762
765
GenerateDirectiveClauseSets (DirLang, OS);
763
766
@@ -778,8 +781,8 @@ void EmitDirectivesFlangImpl(const DirectiveLanguage &DirLang,
778
781
GenerateFlangClausesParser (DirLang, OS);
779
782
}
780
783
781
- void GenerateClauseClassMacro (const DirectiveLanguage &DirLang,
782
- raw_ostream &OS) {
784
+ static void GenerateClauseClassMacro (const DirectiveLanguage &DirLang,
785
+ raw_ostream &OS) {
783
786
// Generate macros style information for legacy code in clang
784
787
IfDefScope Scope (" GEN_CLANG_CLAUSE_CLASS" , OS);
785
788
@@ -874,8 +877,6 @@ void EmitDirectivesBasicImpl(const DirectiveLanguage &DirLang,
874
877
GenerateIsAllowedClause (DirLang, OS);
875
878
}
876
879
877
- } // namespace
878
-
879
880
namespace llvm {
880
881
881
882
// Generate the implemenation section for the enumeration in the directive
0 commit comments