- Make sure default return/argument types (for methods) default to "id".
- Cache the "id" type in Sema...initialize ObjcIdType and TUScope (oops).
- Fix ActOnInstanceMessage to allow for "id" type receivers...still work to do (next).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42842 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 29f422c..08e1368 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1900,19 +1900,25 @@
assert(receiver && "missing receiver expression");
Expr *RExpr = static_cast<Expr *>(receiver);
- // FIXME (snaroff): checking in this code from Patrick. Needs to be revisited.
- // how do we get the ClassDecl from the receiver expression?
QualType receiverType = RExpr->getType();
- while (receiverType->isPointerType()) {
- PointerType *pointerType = static_cast<PointerType*>(receiverType.getTypePtr());
- receiverType = pointerType->getPointeeType();
+ QualType returnType;
+
+ if (receiverType == GetObjcIdType()) {
+ returnType = Context.IntTy; // FIXME:just a placeholder
+ } else {
+ // FIXME (snaroff): checking in this code from Patrick. Needs to be revisited.
+ // how do we get the ClassDecl from the receiver expression?
+ while (receiverType->isPointerType()) {
+ PointerType *pointerType = static_cast<PointerType*>(receiverType.getTypePtr());
+ receiverType = pointerType->getPointeeType();
+ }
+ assert(ObjcInterfaceType::classof(receiverType.getTypePtr()) && "bad receiver type");
+ ObjcInterfaceDecl* ClassDecl = static_cast<ObjcInterfaceType*>(
+ receiverType.getTypePtr())->getDecl();
+ ObjcMethodDecl *Method = ClassDecl->lookupInstanceMethod(Sel);
+ assert(Method && "missing method declaration");
+ returnType = Method->getMethodType();
}
- assert(ObjcInterfaceType::classof(receiverType.getTypePtr()) && "bad receiver type");
- ObjcInterfaceDecl* ClassDecl = static_cast<ObjcInterfaceType*>(
- receiverType.getTypePtr())->getDecl();
- ObjcMethodDecl *Method = ClassDecl->lookupInstanceMethod(Sel);
- assert(Method && "missing method declaration");
- QualType returnType = Method->getMethodType();
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
return new ObjCMessageExpr(RExpr, Sel, returnType, lbrac, rbrac, ArgExprs);
}