Skip to content

Commit 4b9d9cc

Browse files
committed
update formatting
1 parent 482e1ac commit 4b9d9cc

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -416,22 +416,25 @@ class DeclAndTypePrinter::Implementation
416416

417417
os << '\n';
418418
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+
",");
423426
// TODO: allow custom name for this special case
424427
auto resilientUnknownDefaultCaseName = "unknownDefault";
425428
if (ED->isResilient()) {
426429
os << ",\n " << resilientUnknownDefaultCaseName;
427430
}
428431
os << "\n };\n\n"; // enum class cases' closing bracket
429-
432+
430433
// Printing struct, is, and get functions for each case
431434
DeclAndTypeClangFunctionPrinter clangFuncPrinter(
432435
os, owningPrinter.prologueOS, owningPrinter.typeMapping,
433436
owningPrinter.interopContext);
434-
437+
435438
auto printIsFunction = [&](StringRef caseName, EnumDecl *ED) {
436439
os << " inline bool is";
437440
std::string name;
@@ -446,7 +449,7 @@ class DeclAndTypePrinter::Implementation
446449
os << ";\n";
447450
os << " }\n";
448451
};
449-
452+
450453
auto printGetFunction = [&](EnumElementDecl *elementDecl) {
451454
auto associatedValueList = elementDecl->getParameterList();
452455
// TODO: add tuple type support
@@ -458,10 +461,10 @@ class DeclAndTypePrinter::Implementation
458461
OptionalTypeKind optKind;
459462
std::tie(firstType, optKind) =
460463
getObjectTypeAndOptionality(firstTypeDecl, firstType);
461-
464+
462465
auto name = elementDecl->getNameStr().str();
463466
name[0] = std::toupper(name[0]);
464-
467+
465468
// FIXME: may have to forward declare return type
466469
os << " inline ";
467470
clangFuncPrinter.printClangFunctionReturnType(
@@ -492,7 +495,8 @@ class DeclAndTypePrinter::Implementation
492495
} else {
493496
os << " return ";
494497
syntaxPrinter.printModuleNamespaceQualifiersIfNeeded(
495-
firstTypeDecl->getModuleContext(), elementDecl->getParentEnum()->getModuleContext());
498+
firstTypeDecl->getModuleContext(),
499+
elementDecl->getParentEnum()->getModuleContext());
496500
os << cxx_synthesis::getCxxImplNamespaceName();
497501
os << "::";
498502
ClangValueTypePrinter::printCxxImplClassName(os, firstTypeDecl);
@@ -503,9 +507,9 @@ class DeclAndTypePrinter::Implementation
503507
os << "::initializeWithTake(result, payloadFromDestruction);\n";
504508
os << " });\n";
505509
}
506-
os << " }\n"; // closing bracket of get function
510+
os << " }\n"; // closing bracket of get function
507511
};
508-
512+
509513
auto printStruct = [&](StringRef caseName, EnumElementDecl *elementDecl) {
510514
os << " static struct { // impl struct for case " << caseName << '\n';
511515
os << " inline constexpr operator cases() const {\n";
@@ -519,7 +523,7 @@ class DeclAndTypePrinter::Implementation
519523
os << " operator()(";
520524
// TODO: implement parameter for associated value
521525
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
523527
os << " return ";
524528
syntaxPrinter.printBaseName(elementDecl->getParentEnum());
525529
os << "::_make();\n";
@@ -541,7 +545,7 @@ class DeclAndTypePrinter::Implementation
541545
}
542546
os << '\n';
543547
}
544-
548+
545549
if (ED->isResilient()) {
546550
// Printing struct for unknownDefault
547551
printStruct(resilientUnknownDefaultCaseName, /* elementDecl */ nullptr);
@@ -550,7 +554,7 @@ class DeclAndTypePrinter::Implementation
550554
os << '\n';
551555
}
552556
os << '\n';
553-
557+
554558
// Printing operator cases()
555559
os << " inline operator cases() const {\n";
556560
if (ED->isResilient()) {
@@ -573,7 +577,7 @@ class DeclAndTypePrinter::Implementation
573577
os << " default: abort();\n";
574578
os << " }\n"; // switch's closing bracket
575579
}
576-
os << " }\n"; // operator cases()'s closing bracket
580+
os << " }\n"; // operator cases()'s closing bracket
577581
os << "\n";
578582
});
579583
os << outOfLineDefinitions;

lib/PrintAsClang/PrintClangValueType.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ void ClangValueTypePrinter::printValueTypeDecl(
257257
os << "};\n";
258258
// Print the definition of enum static struct data memebers
259259
if (isa<EnumDecl>(typeDecl)) {
260-
auto tagMapping = interopContext.getIrABIDetails().getEnumTagMapping(cast<EnumDecl>(typeDecl));
261-
for (const auto& pair : tagMapping) {
260+
auto tagMapping = interopContext.getIrABIDetails().getEnumTagMapping(
261+
cast<EnumDecl>(typeDecl));
262+
for (const auto &pair : tagMapping) {
262263
os << "decltype(";
263264
printer.printBaseName(typeDecl);
264265
os << "::";

0 commit comments

Comments
 (0)