[cfe-commits] r103708 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaObjCXX/deduction.mm

John McCall rjmccall at apple.com
Thu May 13 01:39:13 PDT 2010


Author: rjmccall
Date: Thu May 13 03:39:13 2010
New Revision: 103708

URL: http://llvm.org/viewvc/llvm-project?rev=103708&view=rev
Log:
Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
magic type that 'id' is a pointer to.


Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaObjCXX/deduction.mm

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=103708&r1=103707&r2=103708&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu May 13 03:39:13 2010
@@ -2445,16 +2445,24 @@
     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());       

Modified: cfe/trunk/test/SemaObjCXX/deduction.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/deduction.mm?rev=103708&r1=103707&r2=103708&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/deduction.mm (original)
+++ cfe/trunk/test/SemaObjCXX/deduction.mm Thu May 13 03:39:13 2010
@@ -21,4 +21,8 @@
   void test(NSString *S) {
     RetainPtr<NSString*> ptr(S);
   }
+
+  void test(id S) {
+    RetainPtr<id> ptr(S);
+  }
 }





More information about the cfe-commits mailing list