]> granicus.if.org Git - clang/commitdiff
objc rewriter - more fixes to support compiling the rewritten
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 10 Sep 2011 17:01:56 +0000 (17:01 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 10 Sep 2011 17:01:56 +0000 (17:01 +0000)
test case having instancetype. Fix in rewriter is unrelated to
using of instancetype. Test case uses other feature not yet
supported in the rewriter. There is more work to do, but this
is an ongoing task and not urgent at this time.

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

lib/Rewrite/RewriteObjC.cpp
test/Rewriter/instancetype-test.mm

index db59b518b731174afd3bc702bda4ddff1f2b50b2..2e118e85f25d4880c3783566f9f64c1a88e9d2ba 100644 (file)
@@ -420,8 +420,14 @@ namespace {
       else if (T->isObjCQualifiedClassType())
         T = Context->getObjCClassType();
       else if (T->isObjCObjectPointerType() &&
-               T->getPointeeType()->isObjCQualifiedInterfaceType())
-        T = Context->getObjCIdType();
+               T->getPointeeType()->isObjCQualifiedInterfaceType()) {
+        if (const ObjCObjectPointerType * OBJPT =
+              T->getAsObjCInterfacePointerType()) {
+          const ObjCInterfaceType *IFaceT = OBJPT->getInterfaceType();
+          T = QualType(IFaceT, 0);
+          T = Context->getPointerType(T);
+        }
+     }
     }
     
     // FIXME: This predicate seems like it would be useful to add to ASTContext.
@@ -3124,8 +3130,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
       (void)convertBlockPointerToFunctionPointer(t);
       ArgTypes.push_back(t);
     }
-    returnType = OMD->getResultType()->isObjCQualifiedIdType()
-                   ? Context->getObjCIdType() : OMD->getResultType();
+    returnType = Exp->getType();
+    convertToUnqualifiedObjCType(returnType);
     (void)convertBlockPointerToFunctionPointer(returnType);
   } else {
     returnType = Context->getObjCIdType();
index 26f9ba2590d530901a4afe01d68f430b89b46d83..97fbe0950da5f097eaf2f5374a0fbc150d7cb698 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 
 void *sel_registerName(const char *);
 
@@ -62,7 +63,8 @@ void test_instancetype_narrow_method_search() {
 
   // Exact type checks
   // Message sends to Class.
-  Subclass1<Proto1> *sc1proto1_2 = [[[sc1proto1 class] alloc] init];
+  // FIXME. This is not supported due to missing capability in rewriter and not due to instancetype issues
+  //  Subclass1<Proto1> *sc1proto1_2 = [[[sc1proto1 class] alloc] init];
 
   // Property access
   [sc1proto1.self methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}