[cfe-commits] r52005 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExprObjC.cpp test/Sema/objc-method-lookup.m
Steve Naroff
snaroff at apple.com
Thu Jun 5 07:49:39 PDT 2008
Author: snaroff
Date: Thu Jun 5 09:49:39 2008
New Revision: 52005
URL: http://llvm.org/viewvc/llvm-project?rev=52005&view=rev
Log:
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.
Added:
cfe/trunk/test/Sema/objc-method-lookup.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=52005&r1=52004&r2=52005&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jun 5 09:49:39 2008
@@ -42,15 +42,17 @@
// Insert the invisible arguments, self and _cmd!
PI.Ident = &Context.Idents.get("self");
PI.IdentLoc = SourceLocation(); // synthesized vars have a null location.
- QualType selfTy = Context.getObjCIdType();
+ QualType selfTy;
if (MDecl->isInstance()) {
+ selfTy = Context.getObjCIdType();
if (ObjCInterfaceDecl *OID = MDecl->getClassInterface()) {
// There may be no interface context due to error in declaration of the
// interface (which has been reported). Recover gracefully
selfTy = Context.getObjCInterfaceType(OID);
selfTy = Context.getPointerType(selfTy);
}
- }
+ } else // we have a factory method.
+ selfTy = Context.getObjCClassType();
CurMethodDecl->setSelfDecl(CreateImplicitParameter(FnBodyScope, PI.Ident,
PI.IdentLoc, selfTy));
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=52005&r1=52004&r2=52005&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Jun 5 09:49:39 2008
@@ -223,8 +223,7 @@
receiverType = RExpr->getType().getCanonicalType().getUnqualifiedType();
- if (receiverType == Context.getObjCIdType().getCanonicalType() ||
- receiverType == Context.getObjCClassType().getCanonicalType()) {
+ if (receiverType == Context.getObjCIdType().getCanonicalType()) {
Method = InstanceMethodPool[Sel].Method;
if (!Method)
Method = FactoryMethodPool[Sel].Method;
@@ -238,6 +237,29 @@
if (CheckMessageArgumentTypes(ArgExprs, Sel.getNumArgs(), Method))
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 {
bool receiverIsQualId = isa<ObjCQualifiedIdType>(receiverType);
// FIXME (snaroff): checking in this code from Patrick. Needs to be
Added: cfe/trunk/test/Sema/objc-method-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-method-lookup.m?rev=52005&view=auto
==============================================================================
--- cfe/trunk/test/Sema/objc-method-lookup.m (added)
+++ cfe/trunk/test/Sema/objc-method-lookup.m Thu Jun 5 09:49:39 2008
@@ -0,0 +1,40 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+
+ at protocol NSObject
+- (BOOL) isEqual:(id) object;
+ at end
+
+ at interface NSObject < NSObject > {} @end
+
+ at class NSString, NSPort;
+
+ at interface NSPortNameServer:NSObject
++ (NSPortNameServer *) systemDefaultPortNameServer;
+ at end
+
+ at interface NSMachBootstrapServer:NSPortNameServer + (id) sharedInstance; @end
+
+enum {
+ NSWindowsNTOperatingSystem = 1, NSWindows95OperatingSystem, NSSolarisOperatingSystem, NSHPUXOperatingSystem, NSMACHOperatingSystem, NSSunOSOperatingSystem, NSOSF1OperatingSystem
+};
+
+ at interface NSRunLoop:NSObject {} @end
+
+ at interface NSRunLoop(NSRunLoopConveniences)
+- (void) run;
+ at end
+
+extern NSString *const NSWillBecomeMultiThreadedNotification;
+
+ at interface SenTestTool:NSObject {}
+ at end
+
+ at implementation SenTestTool
++ (void) initialize {}
++(SenTestTool *) sharedInstance {}
+-(int) run {}
++(int) run {
+ return[[self sharedInstance] run];
+}
+ at end
More information about the cfe-commits
mailing list