]> granicus.if.org Git - clang/commitdiff
Objective-C. provide legacy encoding of *id and *Class types
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 28 Jan 2014 20:41:15 +0000 (20:41 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 28 Jan 2014 20:41:15 +0000 (20:41 +0000)
instead of crashing.  // rdar://15824769.

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

lib/AST/ASTContext.cpp
test/CodeGenObjC/encode-test.m

index ad3bf5105dd29dc55957241cbf5bef68cd68edd7..9ee624c98b305653ea7e540eaab5fd99e27831ca 100644 (file)
@@ -5440,7 +5440,19 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     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();
index d6e7b6dfccad40ab7a1a7d9b77aa430cd99fd94d..a310a621ecf45c313ae69ea3f0bede50415d3e19 100644 (file)
@@ -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"