@@ -117,20 +117,21 @@ static void addCppExtensionsToStdlibType(const NominalTypeDecl *typeDecl,
117
117
" uint32_t _3;\n "
118
118
" #endif\n "
119
119
" };\n " ;
120
- cPrologueOS << " static inline struct swift_interop_stub_Swift_String "
121
- " swift_interop_passDirect_Swift_String(const char * "
122
- " _Nonnull value) {\n "
123
- " struct swift_interop_stub_Swift_String result;\n "
124
- " #if UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu\n "
125
- " memcpy(&result._1, value, 8);\n "
126
- " memcpy(&result._2, value + 8, 8);\n "
127
- " #elif UINTPTR_MAX == 0xFFFFFFFF\n "
128
- " memcpy(&result._1, value, 4);\n "
129
- " memcpy(&result._2, value + 4, 4);\n "
130
- " memcpy(&result._3, value + 8, 4);\n "
131
- " #endif\n "
132
- " return result;\n "
133
- " }\n " ;
120
+ cPrologueOS
121
+ << " static SWIFT_INLINE_THUNK struct swift_interop_stub_Swift_String "
122
+ " swift_interop_passDirect_Swift_String(const char * "
123
+ " _Nonnull value) {\n "
124
+ " struct swift_interop_stub_Swift_String result;\n "
125
+ " #if UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu\n "
126
+ " memcpy(&result._1, value, 8);\n "
127
+ " memcpy(&result._2, value + 8, 8);\n "
128
+ " #elif UINTPTR_MAX == 0xFFFFFFFF\n "
129
+ " memcpy(&result._1, value, 4);\n "
130
+ " memcpy(&result._2, value + 4, 4);\n "
131
+ " memcpy(&result._3, value + 8, 4);\n "
132
+ " #endif\n "
133
+ " return result;\n "
134
+ " }\n " ;
134
135
cPrologueOS << " SWIFT_EXTERN void *_Nonnull "
135
136
" $sSS10FoundationE19_bridgeToObjectiveCSo8NSStringCyF(swift_interop_stub_"
136
137
" Swift_String) SWIFT_NOEXCEPT SWIFT_CALL;\n " ;
@@ -272,15 +273,18 @@ void ClangValueTypePrinter::printValueTypeDecl(
272
273
*genericSignature);
273
274
274
275
// Print out the destructor.
275
- os << " inline ~" ;
276
+ os << " " ;
277
+ printer.printInlineForThunk ();
278
+ os << ' ~' ;
276
279
printer.printBaseName (typeDecl);
277
280
os << " () {\n " ;
278
281
ClangValueTypePrinter::printValueWitnessTableAccessAsVariable (
279
282
os, typeMetadataFuncName, typeMetadataFuncGenericParams);
280
283
os << " vwTable->destroy(_getOpaquePointer(), metadata._0);\n " ;
281
284
os << " }\n " ;
282
285
283
- os << " inline " ;
286
+ os << " " ;
287
+ printer.printInlineForThunk ();
284
288
printer.printBaseName (typeDecl);
285
289
os << " (const " ;
286
290
printer.printBaseName (typeDecl);
@@ -298,7 +302,8 @@ void ClangValueTypePrinter::printValueTypeDecl(
298
302
os << " }\n " ;
299
303
300
304
// FIXME: implement the move constructor.
301
- os << " [[noreturn]] inline " ;
305
+ os << " [[noreturn]] " ;
306
+ printer.printInlineForThunk ();
302
307
printer.printBaseName (typeDecl);
303
308
os << " (" ;
304
309
printer.printBaseName (typeDecl);
@@ -311,7 +316,8 @@ void ClangValueTypePrinter::printValueTypeDecl(
311
316
os << " private:\n " ;
312
317
313
318
// Print out private default constructor.
314
- os << " inline " ;
319
+ os << " " ;
320
+ printer.printInlineForThunk ();
315
321
printer.printBaseName (typeDecl);
316
322
// FIXME: make noexcept.
317
323
if (isOpaqueLayout) {
@@ -324,7 +330,8 @@ void ClangValueTypePrinter::printValueTypeDecl(
324
330
}
325
331
// Print out '_make' function which returns an unitialized instance for
326
332
// passing to Swift.
327
- os << " static inline " ;
333
+ os << " static " ;
334
+ printer.printInlineForThunk ();
328
335
printer.printBaseName (typeDecl);
329
336
os << " _make() {" ;
330
337
if (isOpaqueLayout) {
@@ -340,30 +347,40 @@ void ClangValueTypePrinter::printValueTypeDecl(
340
347
os << " (); }\n " ;
341
348
}
342
349
// Print out the private accessors to the underlying Swift value storage.
343
- os << " inline const char * _Nonnull _getOpaquePointer() const { return "
350
+ os << " " ;
351
+ printer.printInlineForThunk ();
352
+ os << " const char * _Nonnull _getOpaquePointer() const { return "
344
353
" _storage" ;
345
354
if (isOpaqueLayout)
346
355
os << " .getOpaquePointer()" ;
347
356
os << " ; }\n " ;
348
- os << " inline char * _Nonnull _getOpaquePointer() { return _storage" ;
357
+ os << " " ;
358
+ printer.printInlineForThunk ();
359
+ os << " char * _Nonnull _getOpaquePointer() { return _storage" ;
349
360
if (isOpaqueLayout)
350
361
os << " .getOpaquePointer()" ;
351
362
os << " ; }\n " ;
352
363
os << " \n " ;
353
364
// Print out helper function for enums
354
365
if (isa<EnumDecl>(typeDecl)) {
355
- os << " inline char * _Nonnull _destructiveProjectEnumData() {\n " ;
366
+ os << " " ;
367
+ printer.printInlineForThunk ();
368
+ os << " char * _Nonnull _destructiveProjectEnumData() {\n " ;
356
369
printEnumVWTableVariable ();
357
370
os << " enumVWTable->destructiveProjectEnumData(_getOpaquePointer(), "
358
371
" metadata._0);\n " ;
359
372
os << " return _getOpaquePointer();\n " ;
360
373
os << " }\n " ;
361
- os << " inline void _destructiveInjectEnumTag(unsigned tag) {\n " ;
374
+ os << " " ;
375
+ printer.printInlineForThunk ();
376
+ os << " void _destructiveInjectEnumTag(unsigned tag) {\n " ;
362
377
printEnumVWTableVariable ();
363
378
os << " enumVWTable->destructiveInjectEnumTag(_getOpaquePointer(), tag, "
364
379
" metadata._0);\n " ;
365
380
os << " }\n " ;
366
- os << " inline unsigned _getEnumTag() const {\n " ;
381
+ os << " " ;
382
+ printer.printInlineForThunk ();
383
+ os << " unsigned _getEnumTag() const {\n " ;
367
384
printEnumVWTableVariable ();
368
385
os << " return enumVWTable->getEnumTag(_getOpaquePointer(), "
369
386
" metadata._0);\n " ;
@@ -399,18 +416,23 @@ void ClangValueTypePrinter::printValueTypeDecl(
399
416
ClangSyntaxPrinter (os).printGenericSignatureInnerStaticAsserts (
400
417
*genericSignature);
401
418
402
- os << " static inline char * _Nonnull getOpaquePointer(" ;
419
+ os << " static " ;
420
+ ClangSyntaxPrinter (os).printInlineForThunk ();
421
+ os << " char * _Nonnull getOpaquePointer(" ;
403
422
printCxxTypeName (os, typeDecl, moduleContext);
404
423
printGenericParamRefs (os);
405
424
os << " &object) { return object._getOpaquePointer(); }\n " ;
406
425
407
- os << " static inline const char * _Nonnull getOpaquePointer(const " ;
426
+ os << " static " ;
427
+ ClangSyntaxPrinter (os).printInlineForThunk ();
428
+ os << " const char * _Nonnull getOpaquePointer(const " ;
408
429
printCxxTypeName (os, typeDecl, moduleContext);
409
430
printGenericParamRefs (os);
410
431
os << " &object) { return object._getOpaquePointer(); }\n " ;
411
432
412
433
os << " template<class T>\n " ;
413
- os << " static inline " ;
434
+ os << " static " ;
435
+ ClangSyntaxPrinter (os).printInlineForThunk ();
414
436
printCxxTypeName (os, typeDecl, moduleContext);
415
437
printGenericParamRefs (os);
416
438
os << " returnNewValue(T callable) {\n " ;
@@ -422,7 +444,9 @@ void ClangValueTypePrinter::printValueTypeDecl(
422
444
os << " return result;\n " ;
423
445
os << " }\n " ;
424
446
// Print out helper function for initializeWithTake
425
- os << " static inline void initializeWithTake(char * _Nonnull "
447
+ os << " static " ;
448
+ ClangSyntaxPrinter (os).printInlineForThunk ();
449
+ os << " void initializeWithTake(char * _Nonnull "
426
450
" destStorage, char * _Nonnull srcStorage) {\n " ;
427
451
ClangValueTypePrinter::printValueWitnessTableAccessAsVariable (
428
452
os, typeMetadataFuncName, typeMetadataFuncGenericParams);
@@ -565,7 +589,9 @@ void ClangValueTypePrinter::printTypeGenericTraits(
565
589
/* moduleContext=*/ nullptr );
566
590
}
567
591
os << " > {\n " ;
568
- os << " static inline void * _Nonnull getTypeMetadata() {\n " ;
592
+ os << " static " ;
593
+ ClangSyntaxPrinter (os).printInlineForThunk ();
594
+ os << " void * _Nonnull getTypeMetadata() {\n " ;
569
595
os << " return " ;
570
596
if (!typeDecl->hasClangNode ()) {
571
597
printer.printBaseName (typeDecl->getModuleContext ());
0 commit comments