r213076 - Objective-C IRGen. Fixes an inconsistant linkage of

Fariborz Jahanian fjahanian at apple.com
Tue Jul 15 10:14:38 PDT 2014


Author: fjahanian
Date: Tue Jul 15 12:14:34 2014
New Revision: 213076

URL: http://llvm.org/viewvc/llvm-project?rev=213076&view=rev
Log:
Objective-C IRGen. Fixes an inconsistant linkage of
ObC's metaclass metadata with its class metadata which
results in an assert. rdar://17633301


Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/test/CodeGenObjC/weak-metaclass-visibility.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=213076&r1=213075&r2=213076&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Jul 15 12:14:34 2014
@@ -5520,8 +5520,10 @@ void CGObjCNonFragileABIMac::FinishNonFr
     assert(ID);
     if (ObjCImplementationDecl *IMP = ID->getImplementation())
       // We are implementing a weak imported interface. Give it external linkage
-      if (ID->isWeakImported() && !IMP->isWeakImported())
+      if (ID->isWeakImported() && !IMP->isWeakImported()) {
         DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage);
+        DefinedMetaClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage);
+      }
   }
   
   AddModuleClassList(DefinedClasses,
@@ -5821,11 +5823,6 @@ void CGObjCNonFragileABIMac::GenerateCla
                                   ID->getClassInterface()->isWeakImported());
     IsAGV = GetClassGlobal(ObjCMetaClassName + ClassName,
                            ID->getClassInterface()->isWeakImported());
-
-    // We are implementing a weak imported interface. Give it external
-    // linkage.
-    if (!ID->isWeakImported() && ID->getClassInterface()->isWeakImported())
-      IsAGV->setLinkage(llvm::GlobalVariable::ExternalLinkage);
   } else {
     // Has a root. Current class is not a root.
     const ObjCInterfaceDecl *Root = ID->getClassInterface();
@@ -5847,7 +5844,7 @@ void CGObjCNonFragileABIMac::GenerateCla
   std::string TClassName = ObjCMetaClassName + ClassName;
   llvm::GlobalVariable *MetaTClass = BuildClassMetaData(
       TClassName, IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden,
-      ID->isWeakImported());
+      ID->getClassInterface()->isWeakImported());
   DefinedMetaClasses.push_back(MetaTClass);
 
   // Metadata for the class

Modified: cfe/trunk/test/CodeGenObjC/weak-metaclass-visibility.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/weak-metaclass-visibility.m?rev=213076&r1=213075&r2=213076&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/weak-metaclass-visibility.m (original)
+++ cfe/trunk/test/CodeGenObjC/weak-metaclass-visibility.m Tue Jul 15 12:14:34 2014
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -emit-llvm  -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -o - %s | FileCheck %s
 // rdar://16206443
 
 @interface NSObject 
@@ -43,3 +45,15 @@ __attribute__((weak_import))
 
 // CHECK: @"OBJC_METACLASS_$_NSURLQueryItem" = extern_weak global
 // CHECK: @"OBJC_CLASS_$_NSURLQueryItem" = extern_weak global
+
+// rdar://17633301
+ at interface AVScheduledAudioParameters @end // isWeakImported is true!!
+
+ at interface XXXX : AVScheduledAudioParameters // is isWeakImported() true
+ at end
+
+ at implementation AVScheduledAudioParameters @end
+ at implementation XXXX @end
+
+// CHECK: @"OBJC_CLASS_$_AVScheduledAudioParameters" = global %struct._class_t
+// CHECK: @"OBJC_METACLASS_$_AVScheduledAudioParameters" = global %struct._class_t 





More information about the cfe-commits mailing list