@@ -281,13 +281,8 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
281281 OS << " #include <cstddef>\n " ; // for size_t
282282 OS << " #include <utility>\n " ; // for std::pair
283283 OS << " \n " ;
284- OS << " namespace llvm {\n " ;
285-
286- // Open namespaces defined in the directive language
287- SmallVector<StringRef, 2 > Namespaces;
288- SplitString (DirLang.getCppNamespace (), Namespaces, " ::" );
289- for (auto Ns : Namespaces)
290- OS << " namespace " << Ns << " {\n " ;
284+ NamespaceEmitter LlvmNS (OS, " llvm" );
285+ NamespaceEmitter DirLangNS (OS, DirLang.getCppNamespace ());
291286
292287 if (DirLang.hasEnableBitmaskEnumInNamespace ())
293288 OS << " \n LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();\n " ;
@@ -364,9 +359,7 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
364359 OS << " \n " ;
365360 }
366361
367- // Closing namespaces
368- for (auto Ns : reverse (Namespaces))
369- OS << " } // namespace " << Ns << " \n " ;
362+ DirLangNS.close ();
370363
371364 // These specializations need to be in ::llvm.
372365 for (StringRef Enum : {" Association" , " Category" , " Directive" , " Clause" }) {
@@ -376,9 +369,7 @@ static void emitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
376369 OS << " static constexpr bool is_iterable = true;\n " ;
377370 OS << " };\n " ;
378371 }
379-
380- OS << " } // namespace llvm\n " ;
381-
372+ LlvmNS.close ();
382373 OS << " #endif // LLVM_" << Lang << " _INC\n " ;
383374}
384375
0 commit comments