Skip to content

Commit 760d59e

Browse files
committed
[interop][SwiftToCxx] NFC, use FunctionSignatureModifiers to print 'static'
1 parent 5aafe45 commit 760d59e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ void DeclAndTypeClangFunctionPrinter::printFunctionSignature(
221221
};
222222

223223
// Print any modifiers before the signature.
224+
if (modifiers.isStatic) {
225+
assert(!modifiers.isConst);
226+
os << "static ";
227+
}
224228
if (modifiers.isInline)
225229
os << "inline ";
226230

@@ -469,13 +473,11 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
469473
StringRef swiftSymbolName, Type resultTy, bool isDefinition) {
470474
bool isConstructor = isa<ConstructorDecl>(FD);
471475
os << " ";
472-
if (isConstructor && !isDefinition)
473-
os << "static ";
474476

475-
// FIXME: Full qualifier.
476477
FunctionSignatureModifiers modifiers;
477478
if (isDefinition)
478479
modifiers.qualifierContext = typeDeclContext;
480+
modifiers.isStatic = isConstructor && !isDefinition;
479481
modifiers.isInline = true;
480482
bool isMutating =
481483
isa<FuncDecl>(FD) ? cast<FuncDecl>(FD)->isMutating() : false;

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 isStatic = false;
6869
bool isInline = false;
6970
bool isConst = false;
7071

0 commit comments

Comments
 (0)