r329128 - [ObjC] Use the name specified by objc_runtime_name instead of the class
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 3 15:50:17 PDT 2018
Author: ahatanak
Date: Tue Apr 3 15:50:16 2018
New Revision: 329128
URL: http://llvm.org/viewvc/llvm-project?rev=329128&view=rev
Log:
[ObjC] Use the name specified by objc_runtime_name instead of the class
identifier.
This patch fixes a few places in CGObjCMac.cpp where the class
identifier was used instead of the name specified by objc_runtime_name.
rdar://problem/37910822
Differential Revision: https://reviews.llvm.org/D45101
Added:
cfe/trunk/test/CodeGenObjC/objc-runtime-name.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=329128&r1=329127&r2=329128&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Apr 3 15:50:16 2018
@@ -3401,7 +3401,9 @@ static bool hasMRCWeakIvars(CodeGenModul
See EmitClassExtension();
*/
void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
- DefinedSymbols.insert(ID->getIdentifier());
+ IdentifierInfo *RuntimeName =
+ &CGM.getContext().Idents.get(ID->getObjCRuntimeNameAsString());
+ DefinedSymbols.insert(RuntimeName);
std::string ClassName = ID->getNameAsString();
// FIXME: Gross
@@ -4980,7 +4982,9 @@ llvm::Value *CGObjCMac::EmitClassRef(Cod
if (ID->hasAttr<ObjCRuntimeVisibleAttr>())
return EmitClassRefViaRuntime(CGF, ID, ObjCTypes);
- return EmitClassRefFromId(CGF, ID->getIdentifier());
+ IdentifierInfo *RuntimeName =
+ &CGM.getContext().Idents.get(ID->getObjCRuntimeNameAsString());
+ return EmitClassRefFromId(CGF, RuntimeName);
}
llvm::Value *CGObjCMac::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
Added: cfe/trunk/test/CodeGenObjC/objc-runtime-name.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-runtime-name.m?rev=329128&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc-runtime-name.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc-runtime-name.m Tue Apr 3 15:50:16 2018
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.13.0 -fobjc-runtime=macosx-fragile-10.13.0 -fobjc-subscripting-legacy-runtime -emit-llvm -o - %s | FileCheck %s
+
+// Check that the runtime name is emitted and used instead of the class
+// identifier.
+
+// CHECK: module asm {{.*}}objc_class_name_XYZ=0
+// CHECK: module asm {{.*}}globl .objc_class_name_XYZ
+// CHECK: module asm {{.*}}lazy_reference .objc_class_name_XYZ
+
+// CHECK: @[[OBJC_CLASS_NAME:.*]] = private unnamed_addr constant [4 x i8] c"XYZ{{.*}}, section "__TEXT,__cstring,cstring_literals",
+// CHECK: = private global {{.*}} bitcast ([4 x i8]* @[[OBJC_CLASS_NAME]] to {{.*}}), section "__OBJC,__cls_refs,literal_pointers,no_dead_strip"
+
+__attribute__((objc_root_class,objc_runtime_name("XYZ")))
+ at interface A
++(void)m1;
+ at end
+
+ at implementation A
++(void)m1 {}
+ at end
+
+void test(void) {
+ [A m1];
+}
More information about the cfe-commits
mailing list