ObjcInterfaceDecl* ClassDecl = getObjCInterfaceDecl(receiverName);
ObjcMethodDecl *Method = ClassDecl->lookupClassMethod(Sel);
- assert(Method && "missing method declaration");
- QualType retType = Method->getMethodType();
+ QualType returnType;
+ if (!Method) {
+ Diag(lbrac, diag::warn_method_not_found, std::string("+"), Sel.getName(),
+ SourceRange(lbrac, rbrac));
+ returnType = GetObjcIdType();
+ } else {
+ returnType = Method->getMethodType();
+ }
// Expr *RExpr = global reference to the class symbol...
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
- return new ObjCMessageExpr(receiverName, Sel, retType, lbrac, rbrac,
+ return new ObjCMessageExpr(receiverName, Sel, returnType, lbrac, rbrac,
ArgExprs);
}
if (receiverType == GetObjcIdType()) {
ObjcMethodDecl *Method = InstanceMethodPool[Sel].Method;
- // FIXME: emit a diagnostic. For now, I want a hard error...
- assert(Method && "missing method declaration");
- returnType = Method->getMethodType();
+ if (!Method) {
+ Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
+ SourceRange(lbrac, rbrac));
+ returnType = GetObjcIdType();
+ } else {
+ returnType = Method->getMethodType();
+ }
} else {
// FIXME (snaroff): checking in this code from Patrick. Needs to be
// revisited. how do we get the ClassDecl from the receiver expression?
"bad receiver type");
ObjcInterfaceDecl* ClassDecl = static_cast<ObjcInterfaceType*>(
receiverType.getTypePtr())->getDecl();
+ // FIXME: consider using InstanceMethodPool, since it will be faster
+ // than the following method (which can do *many* linear searches). The
+ // idea is to add class info to InstanceMethodPool...
ObjcMethodDecl *Method = ClassDecl->lookupInstanceMethod(Sel);
- // FIXME: emit a diagnostic. For now, I want a hard error...
- assert(Method && "missing method declaration");
- returnType = Method->getMethodType();
+ if (!Method) {
+ Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
+ SourceRange(lbrac, rbrac));
+ returnType = GetObjcIdType();
+ } else {
+ returnType = Method->getMethodType();
+ }
}
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
return new ObjCMessageExpr(RExpr, Sel, returnType, lbrac, rbrac, ArgExprs);
// CURRENTLY UNUSED (10/15/07). ObjCStringLiteral now uses the hook below.
QualType getCFConstantStringType();
- // This setter/getter represents the actual ObjC type for an NSConstantString.
+ // This setter/getter represents the ObjC type for an NSConstantString.
void setObjcConstantStringInterface(ObjcInterfaceDecl *Decl);
QualType getObjcConstantStringInterface() const {
return ObjcConstantStringType;
}
+ // This setter/getter repreents the ObjC 'id' type. It is setup lazily, by
+ // Sema.
void setObjcIdType(TypedefDecl *Decl);
QualType getObjcIdType() const { return ObjcIdType; }