Fix <rdar://problem/5986833> clang on xcode: incompatible type returning 'void', expected 'int'.
- Changed Sema::ObjCActOnStartOfMethodDef() to more accurately type "self" in factory methods. - Changed Sema::ActOnInstanceMessage() to use the new type to restrict the lookup. llvm-svn: 52005
This commit is contained in:
parent
c775e462a8
commit
25449a5221
|
@ -42,15 +42,17 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
|
||||||
// Insert the invisible arguments, self and _cmd!
|
// Insert the invisible arguments, self and _cmd!
|
||||||
PI.Ident = &Context.Idents.get("self");
|
PI.Ident = &Context.Idents.get("self");
|
||||||
PI.IdentLoc = SourceLocation(); // synthesized vars have a null location.
|
PI.IdentLoc = SourceLocation(); // synthesized vars have a null location.
|
||||||
QualType selfTy = Context.getObjCIdType();
|
QualType selfTy;
|
||||||
if (MDecl->isInstance()) {
|
if (MDecl->isInstance()) {
|
||||||
|
selfTy = Context.getObjCIdType();
|
||||||
if (ObjCInterfaceDecl *OID = MDecl->getClassInterface()) {
|
if (ObjCInterfaceDecl *OID = MDecl->getClassInterface()) {
|
||||||
// There may be no interface context due to error in declaration of the
|
// There may be no interface context due to error in declaration of the
|
||||||
// interface (which has been reported). Recover gracefully
|
// interface (which has been reported). Recover gracefully
|
||||||
selfTy = Context.getObjCInterfaceType(OID);
|
selfTy = Context.getObjCInterfaceType(OID);
|
||||||
selfTy = Context.getPointerType(selfTy);
|
selfTy = Context.getPointerType(selfTy);
|
||||||
}
|
}
|
||||||
}
|
} else // we have a factory method.
|
||||||
|
selfTy = Context.getObjCClassType();
|
||||||
CurMethodDecl->setSelfDecl(CreateImplicitParameter(FnBodyScope, PI.Ident,
|
CurMethodDecl->setSelfDecl(CreateImplicitParameter(FnBodyScope, PI.Ident,
|
||||||
PI.IdentLoc, selfTy));
|
PI.IdentLoc, selfTy));
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
|
||||||
|
|
||||||
receiverType = RExpr->getType().getCanonicalType().getUnqualifiedType();
|
receiverType = RExpr->getType().getCanonicalType().getUnqualifiedType();
|
||||||
|
|
||||||
if (receiverType == Context.getObjCIdType().getCanonicalType() ||
|
if (receiverType == Context.getObjCIdType().getCanonicalType()) {
|
||||||
receiverType == Context.getObjCClassType().getCanonicalType()) {
|
|
||||||
Method = InstanceMethodPool[Sel].Method;
|
Method = InstanceMethodPool[Sel].Method;
|
||||||
if (!Method)
|
if (!Method)
|
||||||
Method = FactoryMethodPool[Sel].Method;
|
Method = FactoryMethodPool[Sel].Method;
|
||||||
|
@ -238,6 +237,29 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
|
||||||
if (CheckMessageArgumentTypes(ArgExprs, Sel.getNumArgs(), Method))
|
if (CheckMessageArgumentTypes(ArgExprs, Sel.getNumArgs(), Method))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else if (receiverType == Context.getObjCClassType().getCanonicalType()) {
|
||||||
|
if (CurMethodDecl) {
|
||||||
|
ObjCInterfaceDecl* ClassDecl = CurMethodDecl->getClassInterface();
|
||||||
|
// If we have an implementation in scope, check "private" methods.
|
||||||
|
if (ClassDecl)
|
||||||
|
if (ObjCImplementationDecl *ImpDecl =
|
||||||
|
ObjCImplementations[ClassDecl->getIdentifier()])
|
||||||
|
Method = ImpDecl->getClassMethod(Sel);
|
||||||
|
}
|
||||||
|
if (!Method)
|
||||||
|
Method = FactoryMethodPool[Sel].Method;
|
||||||
|
if (!Method)
|
||||||
|
Method = InstanceMethodPool[Sel].Method;
|
||||||
|
if (!Method) {
|
||||||
|
Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
|
||||||
|
SourceRange(lbrac, rbrac));
|
||||||
|
returnType = Context.getObjCIdType();
|
||||||
|
} else {
|
||||||
|
returnType = Method->getResultType();
|
||||||
|
if (Sel.getNumArgs())
|
||||||
|
if (CheckMessageArgumentTypes(ArgExprs, Sel.getNumArgs(), Method))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bool receiverIsQualId = isa<ObjCQualifiedIdType>(receiverType);
|
bool receiverIsQualId = isa<ObjCQualifiedIdType>(receiverType);
|
||||||
// FIXME (snaroff): checking in this code from Patrick. Needs to be
|
// FIXME (snaroff): checking in this code from Patrick. Needs to be
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
// RUN: clang -fsyntax-only -verify %s
|
||||||
|
typedef signed char BOOL;
|
||||||
|
|
||||||
|
@protocol NSObject
|
||||||
|
- (BOOL) isEqual:(id) object;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSObject < NSObject > {} @end
|
||||||
|
|
||||||
|
@class NSString, NSPort;
|
||||||
|
|
||||||
|
@interface NSPortNameServer:NSObject
|
||||||
|
+ (NSPortNameServer *) systemDefaultPortNameServer;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSMachBootstrapServer:NSPortNameServer + (id) sharedInstance; @end
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NSWindowsNTOperatingSystem = 1, NSWindows95OperatingSystem, NSSolarisOperatingSystem, NSHPUXOperatingSystem, NSMACHOperatingSystem, NSSunOSOperatingSystem, NSOSF1OperatingSystem
|
||||||
|
};
|
||||||
|
|
||||||
|
@interface NSRunLoop:NSObject {} @end
|
||||||
|
|
||||||
|
@interface NSRunLoop(NSRunLoopConveniences)
|
||||||
|
- (void) run;
|
||||||
|
@end
|
||||||
|
|
||||||
|
extern NSString *const NSWillBecomeMultiThreadedNotification;
|
||||||
|
|
||||||
|
@interface SenTestTool:NSObject {}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SenTestTool
|
||||||
|
+ (void) initialize {}
|
||||||
|
+(SenTestTool *) sharedInstance {}
|
||||||
|
-(int) run {}
|
||||||
|
+(int) run {
|
||||||
|
return[[self sharedInstance] run];
|
||||||
|
}
|
||||||
|
@end
|
Loading…
Reference in New Issue