File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,13 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
322
322
void visitClassDecl (ClassDecl *CD) {
323
323
printDocumentationComment (CD);
324
324
325
+ // This is just for testing, so we check explicitly for the attribute instead
326
+ // of asking if the class is weak imported. If the class has availablility,
327
+ // we'll print a SWIFT_AVAIALBLE() which implies __attribute__((weak_imported))
328
+ // already.
329
+ if (CD->getAttrs ().hasAttribute <WeakLinkedAttr>())
330
+ os << " SWIFT_WEAK_IMPORT\n " ;
331
+
325
332
bool hasResilientAncestry =
326
333
CD->checkAncestry ().contains (AncestryFlags::ResilientOther);
327
334
if (hasResilientAncestry) {
@@ -2717,6 +2724,9 @@ class ModuleWriter {
2717
2724
" #if !defined(SWIFT_AVAILABILITY)\n "
2718
2725
" # define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))\n "
2719
2726
" #endif\n "
2727
+ " #if !defined(SWIFT_WEAK_IMPORT)\n "
2728
+ " # define SWIFT_WEAK_IMPORT __attribute__((weak_import))\n "
2729
+ " #endif\n "
2720
2730
" #if !defined(SWIFT_DEPRECATED)\n "
2721
2731
" # define SWIFT_DEPRECATED __attribute__((deprecated))\n "
2722
2732
" #endif\n "
Original file line number Diff line number Diff line change @@ -805,3 +805,9 @@ public class NonObjCClass { }
805
805
@objc func referenceSingleGenericClass( _: SingleImportedObjCGeneric < AnyObject > ? ) { }
806
806
}
807
807
// CHECK: @end
808
+
809
+ // CHECK: SWIFT_WEAK_IMPORT
810
+ // CHECK-NEXT: SWIFT_CLASS("_TtC7classes17WeakImportedClass")
811
+ // CHECK-NEXT: @interface WeakImportedClass
812
+ // CHECK-NEXT: @end
813
+ @_weakLinked @objc class WeakImportedClass { }
You can’t perform that action at this time.
0 commit comments