]> granicus.if.org Git - clang/commitdiff
Honor the objc_runtime_name attribute when encoding class/protocol names.
authorDouglas Gregor <dgregor@apple.com>
Tue, 16 Jun 2015 21:04:55 +0000 (21:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 16 Jun 2015 21:04:55 +0000 (21:04 +0000)
While the rest of the Objective-C metadata seems to honor
objc_runtime_name, the encoding strings produced by, e.g., @encode and
property meta, were not. Fixes rdar://problem/21408305.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239852 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGenObjC/objc-asm-attribute-test.m

index 4a831d90e64587ca59e4705426fcf232af418c67..049eebd82b66b1fbffabdb7ae856c36d5a791fa0 100644 (file)
@@ -5610,8 +5610,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     // @encode(class_name)
     ObjCInterfaceDecl *OI = OIT->getDecl();
     S += '{';
-    const IdentifierInfo *II = OI->getIdentifier();
-    S += II->getName();
+    S += OI->getObjCRuntimeNameAsString();
     S += '=';
     SmallVector<const ObjCIvarDecl*, 32> Ivars;
     DeepCollectObjCIvars(OI, true, Ivars);
@@ -5654,7 +5653,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
         S += '"';
         for (const auto *I : OPT->quals()) {
           S += '<';
-          S += I->getNameAsString();
+          S += I->getObjCRuntimeNameAsString();
           S += '>';
         }
         S += '"';
@@ -5678,7 +5677,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
         for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
           if (cast<FieldDecl>(Ivars[i]) == FD) {
             S += '{';
-            S += OI->getIdentifier()->getName();
+            S += OI->getObjCRuntimeNameAsString();
             S += '}';
             return;
           }
@@ -5696,10 +5695,10 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     if (OPT->getInterfaceDecl() && 
         (FD || EncodingProperty || EncodeClassNames)) {
       S += '"';
-      S += OPT->getInterfaceDecl()->getIdentifier()->getName();
+      S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
       for (const auto *I : OPT->quals()) {
         S += '<';
-        S += I->getNameAsString();
+        S += I->getObjCRuntimeNameAsString();
         S += '>';
       }
       S += '"';
index 589b08ae0eef07202e4542c9357c7cd86d7299c3..7b3a64deb74c68b99f3802c278cb0997dffdc344 100644 (file)
@@ -13,10 +13,19 @@ __attribute__((objc_runtime_name("MySecretNamespace.Protocol2")))
 + (void) ClsMethodP2;
 @end
 
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol3")))
+@protocol Protocol3
+@end
+
 __attribute__((objc_runtime_name("MySecretNamespace.Message")))
 @interface Message <Protocol, Protocol2> {
   id MyIVAR;
 }
+
+@property(retain) Message *msgProp;
+@property(retain) Message<Protocol3> *msgProtoProp;
+@property(retain) id<Protocol3> idProtoProp;
+
 @end
 
 @implementation Message
@@ -46,9 +55,14 @@ id Test16877359() {
     return [SLREarth alloc];
 }
 
-// CHECK: @"OBJC_IVAR_$_MySecretNamespace.Message.MyIVAR" = global i64
+// CHECK: @"OBJC_IVAR_$_MySecretNamespace.Message.MyIVAR" = global i64 0
 // CHECK: @"OBJC_CLASS_$_MySecretNamespace.Message" = global %struct._class_t
 // CHECK: @"OBJC_METACLASS_$_MySecretNamespace.Message" = global %struct._class_t
+
+// CHECK: private global [42 x i8] c"T@\22MySecretNamespace.Message\22,&,V_msgProp\00"
+// CHECK: private global [76 x i8] c"T@\22MySecretNamespace.Message<MySecretNamespace.Protocol3>\22,&,V_msgProtoProp\00"
+// CHECK: private global [50 x i8] c"T@\22<MySecretNamespace.Protocol3>\22,&,V_idProtoProp\00"
+
 // CHECK: @"OBJC_CLASS_$_foo" = external global %struct._class_t
 // CHECK: define internal i8* @"\01-[Message MyMethod]"
 // CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_MySecretNamespace.Message.MyIVAR"