r200338 - Objective-C. provide legacy encoding of *id and *Class types
Fariborz Jahanian
fjahanian at apple.com
Tue Jan 28 12:41:16 PST 2014
Author: fjahanian
Date: Tue Jan 28 14:41:15 2014
New Revision: 200338
URL: http://llvm.org/viewvc/llvm-project?rev=200338&view=rev
Log:
Objective-C. provide legacy encoding of *id and *Class types
instead of crashing. // rdar://15824769.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjC/encode-test.m
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=200338&r1=200337&r2=200338&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jan 28 14:41:15 2014
@@ -5440,7 +5440,19 @@ void ASTContext::getObjCEncodingForTypeI
return;
}
- case Type::ObjCObject:
+ case Type::ObjCObject: {
+ // hack to match legacy encoding of *id and *Class
+ QualType Ty = getObjCObjectPointerType(CT);
+ if (Ty->isObjCIdType()) {
+ S += "{objc_object=}";
+ return;
+ }
+ else if (Ty->isObjCClassType()) {
+ S += "{objc_class=}";
+ return;
+ }
+ }
+
case Type::ObjCInterface: {
// Ignore protocol qualifiers when mangling at this level.
T = T->castAs<ObjCObjectType>()->getBaseType();
Modified: cfe/trunk/test/CodeGenObjC/encode-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test.m?rev=200338&r1=200337&r2=200338&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-test.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test.m Tue Jan 28 14:41:15 2014
@@ -169,3 +169,11 @@ const char g11[] = @encode(void);
// PR14628
// CHECK: @g12 = constant [3 x i8] c"Ai\00"
const char g12[] = @encode(_Atomic(int));
+
+// rdar://15824769
+id test_id = 0;
+Class test_class = 0;
+const char g13[] = @encode(__typeof__(*test_class));
+const char g14[] = @encode(__typeof__(*test_id));
+// CHECK: constant [14 x i8] c"{objc_class=}\00"
+// CHECK: constant [15 x i8] c"{objc_object=}\00"
More information about the cfe-commits
mailing list