@@ -416,22 +416,25 @@ class DeclAndTypePrinter::Implementation
416
416
417
417
os << ' \n ' ;
418
418
os << " enum class cases {" ;
419
- llvm::interleave (elementTagMapping, os, [&](const auto &pair){
420
- os << " \n " ;
421
- syntaxPrinter.printIdentifier (pair.first ->getNameStr ());
422
- }, " ," );
419
+ llvm::interleave (
420
+ elementTagMapping, os,
421
+ [&](const auto &pair) {
422
+ os << " \n " ;
423
+ syntaxPrinter.printIdentifier (pair.first ->getNameStr ());
424
+ },
425
+ " ," );
423
426
// TODO: allow custom name for this special case
424
427
auto resilientUnknownDefaultCaseName = " unknownDefault" ;
425
428
if (ED->isResilient ()) {
426
429
os << " ,\n " << resilientUnknownDefaultCaseName;
427
430
}
428
431
os << " \n };\n\n " ; // enum class cases' closing bracket
429
-
432
+
430
433
// Printing struct, is, and get functions for each case
431
434
DeclAndTypeClangFunctionPrinter clangFuncPrinter (
432
435
os, owningPrinter.prologueOS , owningPrinter.typeMapping ,
433
436
owningPrinter.interopContext );
434
-
437
+
435
438
auto printIsFunction = [&](StringRef caseName, EnumDecl *ED) {
436
439
os << " inline bool is" ;
437
440
std::string name;
@@ -446,7 +449,7 @@ class DeclAndTypePrinter::Implementation
446
449
os << " ;\n " ;
447
450
os << " }\n " ;
448
451
};
449
-
452
+
450
453
auto printGetFunction = [&](EnumElementDecl *elementDecl) {
451
454
auto associatedValueList = elementDecl->getParameterList ();
452
455
// TODO: add tuple type support
@@ -458,10 +461,10 @@ class DeclAndTypePrinter::Implementation
458
461
OptionalTypeKind optKind;
459
462
std::tie (firstType, optKind) =
460
463
getObjectTypeAndOptionality (firstTypeDecl, firstType);
461
-
464
+
462
465
auto name = elementDecl->getNameStr ().str ();
463
466
name[0 ] = std::toupper (name[0 ]);
464
-
467
+
465
468
// FIXME: may have to forward declare return type
466
469
os << " inline " ;
467
470
clangFuncPrinter.printClangFunctionReturnType (
@@ -492,7 +495,8 @@ class DeclAndTypePrinter::Implementation
492
495
} else {
493
496
os << " return " ;
494
497
syntaxPrinter.printModuleNamespaceQualifiersIfNeeded (
495
- firstTypeDecl->getModuleContext (), elementDecl->getParentEnum ()->getModuleContext ());
498
+ firstTypeDecl->getModuleContext (),
499
+ elementDecl->getParentEnum ()->getModuleContext ());
496
500
os << cxx_synthesis::getCxxImplNamespaceName ();
497
501
os << " ::" ;
498
502
ClangValueTypePrinter::printCxxImplClassName (os, firstTypeDecl);
@@ -503,9 +507,9 @@ class DeclAndTypePrinter::Implementation
503
507
os << " ::initializeWithTake(result, payloadFromDestruction);\n " ;
504
508
os << " });\n " ;
505
509
}
506
- os << " }\n " ; // closing bracket of get function
510
+ os << " }\n " ; // closing bracket of get function
507
511
};
508
-
512
+
509
513
auto printStruct = [&](StringRef caseName, EnumElementDecl *elementDecl) {
510
514
os << " static struct { // impl struct for case " << caseName << ' \n ' ;
511
515
os << " inline constexpr operator cases() const {\n " ;
@@ -519,7 +523,7 @@ class DeclAndTypePrinter::Implementation
519
523
os << " operator()(" ;
520
524
// TODO: implement parameter for associated value
521
525
os << " ) const {\n " ;
522
- // TODO: print _make for now; need to implement actual code making an enum
526
+ // TODO: print _make for now; need to print actual code making an enum
523
527
os << " return " ;
524
528
syntaxPrinter.printBaseName (elementDecl->getParentEnum ());
525
529
os << " ::_make();\n " ;
@@ -541,7 +545,7 @@ class DeclAndTypePrinter::Implementation
541
545
}
542
546
os << ' \n ' ;
543
547
}
544
-
548
+
545
549
if (ED->isResilient ()) {
546
550
// Printing struct for unknownDefault
547
551
printStruct (resilientUnknownDefaultCaseName, /* elementDecl */ nullptr );
@@ -550,7 +554,7 @@ class DeclAndTypePrinter::Implementation
550
554
os << ' \n ' ;
551
555
}
552
556
os << ' \n ' ;
553
-
557
+
554
558
// Printing operator cases()
555
559
os << " inline operator cases() const {\n " ;
556
560
if (ED->isResilient ()) {
@@ -573,7 +577,7 @@ class DeclAndTypePrinter::Implementation
573
577
os << " default: abort();\n " ;
574
578
os << " }\n " ; // switch's closing bracket
575
579
}
576
- os << " }\n " ; // operator cases()'s closing bracket
580
+ os << " }\n " ; // operator cases()'s closing bracket
577
581
os << " \n " ;
578
582
});
579
583
os << outOfLineDefinitions;
0 commit comments