@@ -504,28 +504,31 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
504
504
os << " }\n " ;
505
505
}
506
506
507
- void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod (
508
- const NominalTypeDecl *typeDeclContext, const AccessorDecl *accessor,
509
- StringRef swiftSymbolName, Type resultTy, bool isDefinition) {
510
- assert (accessor->isSetter () || accessor->getParameters ()->size () == 0 );
511
- os << " " ;
512
-
507
+ static std::string remapPropertyName (const AccessorDecl *accessor) {
513
508
StringRef propertyName;
514
509
// For a getter or setter, go through the variable or subscript decl.
515
510
propertyName = accessor->getStorage ()->getBaseIdentifier ().str ();
516
-
517
511
std::string name;
518
512
llvm::raw_string_ostream nameOS (name);
519
513
// FIXME: some names are remapped differently. (e.g. isX).
520
514
nameOS << (accessor->isSetter () ? " set" : " get" )
521
515
<< char (std::toupper (propertyName[0 ])) << propertyName.drop_front ();
516
+ nameOS.flush ();
517
+ return name;
518
+ }
519
+
520
+ void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod (
521
+ const NominalTypeDecl *typeDeclContext, const AccessorDecl *accessor,
522
+ StringRef swiftSymbolName, Type resultTy, bool isDefinition) {
523
+ assert (accessor->isSetter () || accessor->getParameters ()->size () == 0 );
524
+ os << " " ;
522
525
523
526
FunctionSignatureModifiers modifiers;
524
527
if (isDefinition)
525
528
modifiers.qualifierContext = typeDeclContext;
526
529
modifiers.isInline = true ;
527
530
modifiers.isConst = accessor->isGetter ();
528
- printFunctionSignature (accessor, nameOS. str ( ), resultTy,
531
+ printFunctionSignature (accessor, remapPropertyName (accessor ), resultTy,
529
532
FunctionSignatureKind::CxxInlineThunk, {}, modifiers);
530
533
if (!isDefinition) {
531
534
os << " ;\n " ;
0 commit comments