Skip to content

Commit 5aafe45

Browse files
committed
[interop][SwiftToCxx] NFC, use FunctionSignatureModifiers to print 'inline'
1 parent 6f86d60 commit 5aafe45

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ void DeclAndTypeClangFunctionPrinter::printFunctionSignature(
220220
}
221221
};
222222

223+
// Print any modifiers before the signature.
224+
if (modifiers.isInline)
225+
os << "inline ";
226+
223227
// Print out the return type.
224228
bool isIndirectReturnType =
225229
kind == FunctionSignatureKind::CFunctionProto &&
@@ -467,11 +471,12 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
467471
os << " ";
468472
if (isConstructor && !isDefinition)
469473
os << "static ";
470-
os << "inline ";
474+
471475
// FIXME: Full qualifier.
472476
FunctionSignatureModifiers modifiers;
473477
if (isDefinition)
474478
modifiers.qualifierContext = typeDeclContext;
479+
modifiers.isInline = true;
475480
bool isMutating =
476481
isa<FuncDecl>(FD) ? cast<FuncDecl>(FD)->isMutating() : false;
477482
modifiers.isConst = !isMutating && !isConstructor;
@@ -501,7 +506,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod(
501506
const NominalTypeDecl *typeDeclContext, const AccessorDecl *accessor,
502507
StringRef swiftSymbolName, Type resultTy, bool isDefinition) {
503508
assert(accessor->isSetter() || accessor->getParameters()->size() == 0);
504-
os << " inline ";
509+
os << " ";
505510

506511
StringRef propertyName;
507512
// For a getter or setter, go through the variable or subscript decl.
@@ -516,6 +521,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod(
516521
FunctionSignatureModifiers modifiers;
517522
if (isDefinition)
518523
modifiers.qualifierContext = typeDeclContext;
524+
modifiers.isInline = true;
519525
modifiers.isConst = accessor->isGetter();
520526
printFunctionSignature(accessor, nameOS.str(), resultTy,
521527
FunctionSignatureKind::CxxInlineThunk, {}, modifiers);

lib/PrintAsClang/PrintClangFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class DeclAndTypeClangFunctionPrinter {
6565
struct FunctionSignatureModifiers {
6666
/// Additional qualifier to add before the function's name.
6767
const NominalTypeDecl *qualifierContext = nullptr;
68+
bool isInline = false;
6869
bool isConst = false;
6970

7071
FunctionSignatureModifiers() {}

0 commit comments

Comments
 (0)