]> granicus.if.org Git - clang/commitdiff
Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
authorJohn McCall <rjmccall@apple.com>
Thu, 13 May 2010 08:39:13 +0000 (08:39 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 13 May 2010 08:39:13 +0000 (08:39 +0000)
magic type that 'id' is a pointer to.

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

lib/Sema/TreeTransform.h
test/SemaObjCXX/deduction.mm

index 4923480737ee5aa6f80201b1cf7881383cc9b93a..35152617336ac2d48c7db13958cf39393914526b 100644 (file)
@@ -2445,16 +2445,24 @@ QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
     return QualType();
 
   QualType Result = TL.getType();
-  if (PointeeType->isObjCInterfaceType()) {
+  if (PointeeType->isObjCInterfaceType() ||
+      PointeeType->isSpecificBuiltinType(BuiltinType::ObjCId)) {
     // A dependent pointer type 'T *' has is being transformed such
     // that an Objective-C class type is being replaced for 'T'. The
     // resulting pointer type is an ObjCObjectPointerType, not a
     // PointerType.
-    const ObjCInterfaceType *IFace = PointeeType->getAs<ObjCInterfaceType>();
+    ObjCProtocolDecl **Protocols = 0;
+    unsigned NumProtocols = 0;
+
+    if (const ObjCInterfaceType *IFace
+          = PointeeType->getAs<ObjCInterfaceType>()) {
+      Protocols = const_cast<ObjCProtocolDecl**>(IFace->qual_begin());
+      NumProtocols = IFace->getNumProtocols();
+    }
+
     Result = SemaRef.Context.getObjCObjectPointerType(PointeeType,
-                                              const_cast<ObjCProtocolDecl **>(
-                                                           IFace->qual_begin()),
-                                              IFace->getNumProtocols());
+                                                      Protocols,
+                                                      NumProtocols);
     
     ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);   
     NewT.setStarLoc(TL.getSigilLoc());       
index 2c153aa9a6657ff77437c4c753c13b887b0b8a6a..0d2fc06dc35ac827ab677a34e43a8e3b4c3ee00e 100644 (file)
@@ -21,4 +21,8 @@ namespace test0 {
   void test(NSString *S) {
     RetainPtr<NSString*> ptr(S);
   }
+
+  void test(id S) {
+    RetainPtr<id> ptr(S);
+  }
 }