aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Rewrite/RewriteObjC.cpp14
-rw-r--r--test/Rewriter/instancetype-test.mm4
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp
index db59b518b7..2e118e85f2 100644
--- a/lib/Rewrite/RewriteObjC.cpp
+++ b/lib/Rewrite/RewriteObjC.cpp
@@ -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();
diff --git a/test/Rewriter/instancetype-test.mm b/test/Rewriter/instancetype-test.mm
index 26f9ba2590..97fbe0950d 100644
--- a/test/Rewriter/instancetype-test.mm
+++ b/test/Rewriter/instancetype-test.mm
@@ -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')}}