@@ -81,14 +81,14 @@ static void generateEnumExports(ArrayRef<const Record *> Records,
8181 std::string N = getIdentifierName (R, Prefix);
8282 OS << " constexpr auto " << N << " = " << Enum << " ::" << N << " ;\n " ;
8383 }
84+ OS << " \n " ;
8485}
8586
8687// Generate enum class. Entries are emitted in the order in which they appear
8788// in the `Records` vector.
8889static void generateEnumClass (ArrayRef<const Record *> Records, raw_ostream &OS,
8990 StringRef Enum, StringRef Prefix,
9091 bool ExportEnums) {
91- OS << " \n " ;
9292 OS << " enum class " << Enum << " {\n " ;
9393 if (!Records.empty ()) {
9494 std::string N;
@@ -104,17 +104,15 @@ static void generateEnumClass(ArrayRef<const Record *> Records, raw_ostream &OS,
104104 OS << " };\n " ;
105105 OS << " \n " ;
106106 OS << " static constexpr std::size_t " << Enum
107- << " _enumSize = " << Records.size () << " ;\n " ;
107+ << " _enumSize = " << Records.size () << " ;\n\n " ;
108108
109109 // Make the enum values available in the defined namespace. This allows us to
110110 // write something like Enum_X if we have a `using namespace <CppNamespace>`.
111111 // At the same time we do not loose the strong type guarantees of the enum
112112 // class, that is we cannot pass an unsigned as Directive without an explicit
113113 // cast.
114- if (ExportEnums) {
115- OS << " \n " ;
114+ if (ExportEnums)
116115 generateEnumExports (Records, OS, Enum, Prefix);
117- }
118116}
119117
120118// Generate enum class with values corresponding to different bit positions.
@@ -127,7 +125,6 @@ static void generateEnumBitmask(ArrayRef<const Record *> Records,
127125 StringRef Type = Records.size () <= 32 ? " uint32_t" : " uint64_t" ;
128126 StringRef TypeSuffix = Records.size () <= 32 ? " U" : " ULL" ;
129127
130- OS << " \n " ;
131128 OS << " enum class " << Enum << " : " << Type << " {\n " ;
132129 std::string LastName;
133130 for (auto [I, R] : llvm::enumerate (Records)) {
@@ -138,17 +135,15 @@ static void generateEnumBitmask(ArrayRef<const Record *> Records,
138135 OS << " };\n " ;
139136 OS << " \n " ;
140137 OS << " static constexpr std::size_t " << Enum
141- << " _enumSize = " << Records.size () << " ;\n " ;
138+ << " _enumSize = " << Records.size () << " ;\n\n " ;
142139
143140 // Make the enum values available in the defined namespace. This allows us to
144141 // write something like Enum_X if we have a `using namespace <CppNamespace>`.
145142 // At the same time we do not loose the strong type guarantees of the enum
146143 // class, that is we cannot pass an unsigned as Directive without an explicit
147144 // cast.
148- if (ExportEnums) {
149- OS << " \n " ;
145+ if (ExportEnums)
150146 generateEnumExports (Records, OS, Enum, Prefix);
151- }
152147}
153148
154149// Generate enums for values that clauses can take.
@@ -170,7 +165,6 @@ static void generateClauseEnumVal(ArrayRef<const Record *> Records,
170165 return ;
171166 }
172167
173- OS << " \n " ;
174168 OS << " enum class " << Enum << " {\n " ;
175169 for (const EnumVal Val : ClauseVals)
176170 OS << " " << Val.getRecordName () << " =" << Val.getValue () << " ,\n " ;
@@ -182,6 +176,7 @@ static void generateClauseEnumVal(ArrayRef<const Record *> Records,
182176 OS << " constexpr auto " << CV->getName () << " = " << Enum
183177 << " ::" << CV->getName () << " ;\n " ;
184178 }
179+ OS << " \n " ;
185180 EnumHelperFuncs += (Twine (" LLVM_ABI " ) + Twine (Enum) + Twine (" get" ) +
186181 Twine (Enum) + Twine (" (StringRef Str);\n " ))
187182 .str ();
@@ -284,7 +279,7 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
284279 NamespaceEmitter DirLangNS (OS, DirLang.getCppNamespace ());
285280
286281 if (DirLang.hasEnableBitmaskEnumInNamespace ())
287- OS << " \n LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ();\n " ;
282+ OS << " LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ();\n \n" ;
288283
289284 // Emit Directive associations
290285 std::vector<const Record *> Associations;
@@ -315,7 +310,6 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
315310 generateClauseEnumVal (DirLang.getClauses (), OS, DirLang, EnumHelperFuncs);
316311
317312 // Generic function signatures
318- OS << " \n " ;
319313 OS << " // Enumeration helper functions\n " ;
320314
321315 OS << " LLVM_ABI std::pair<Directive, directive::VersionRange> get" << Lang
@@ -353,10 +347,7 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
353347 OS << " LLVM_ABI Association getDirectiveAssociation(Directive D);\n " ;
354348 OS << " LLVM_ABI Category getDirectiveCategory(Directive D);\n " ;
355349 OS << " LLVM_ABI SourceLanguage getDirectiveLanguages(Directive D);\n " ;
356- if (EnumHelperFuncs.length () > 0 ) {
357- OS << EnumHelperFuncs;
358- OS << " \n " ;
359- }
350+ OS << EnumHelperFuncs;
360351
361352 DirLangNS.close ();
362353
0 commit comments