r239852 - Honor the objc_runtime_name attribute when encoding class/protocol names.
Douglas Gregor
dgregor at apple.com
Tue Jun 16 14:04:55 PDT 2015
Author: dgregor
Date: Tue Jun 16 16:04:55 2015
New Revision: 239852
URL: http://llvm.org/viewvc/llvm-project?rev=239852&view=rev
Log:
Honor the objc_runtime_name attribute when encoding class/protocol names.
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.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=239852&r1=239851&r2=239852&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jun 16 16:04:55 2015
@@ -5610,8 +5610,7 @@ void ASTContext::getObjCEncodingForTypeI
// @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::getObjCEncodingForTypeI
S += '"';
for (const auto *I : OPT->quals()) {
S += '<';
- S += I->getNameAsString();
+ S += I->getObjCRuntimeNameAsString();
S += '>';
}
S += '"';
@@ -5678,7 +5677,7 @@ void ASTContext::getObjCEncodingForTypeI
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::getObjCEncodingForTypeI
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 += '"';
Modified: cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m?rev=239852&r1=239851&r2=239852&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc-asm-attribute-test.m Tue Jun 16 16:04:55 2015
@@ -13,10 +13,19 @@ __attribute__((objc_runtime_name("MySecr
+ (void) ClsMethodP2;
@end
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol3")))
+ at protocol Protocol3
+ at end
+
__attribute__((objc_runtime_name("MySecretNamespace.Message")))
@interface Message <Protocol, Protocol2> {
id MyIVAR;
}
+
+ at property(retain) Message *msgProp;
+ at property(retain) Message<Protocol3> *msgProtoProp;
+ at 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"
More information about the cfe-commits
mailing list