ObjCMethodDecl *Method,
bool isClassMessage, bool isSuperMessage,
SourceLocation lbrac, SourceLocation rbrac,
+ SourceRange RecRange,
QualType &ReturnType, ExprValueKind &VK) {
SourceLocation SelLoc;
if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
SelectorLocs.back());
// Find the class to which we are sending this message.
if (ReceiverType->isObjCObjectPointerType()) {
- if (ObjCInterfaceDecl *Class =
- ReceiverType->getAs<ObjCObjectPointerType>()->getInterfaceDecl())
- Diag(Class->getLocation(), diag::note_receiver_class_declared);
+ if (ObjCInterfaceDecl *ThisClass =
+ ReceiverType->getAs<ObjCObjectPointerType>()->getInterfaceDecl()) {
+ Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
+ if (!RecRange.isInvalid())
+ if (ThisClass->lookupClassMethod(Sel))
+ Diag(RecRange.getBegin(),diag::note_receiver_expr_here)
+ << FixItHint::CreateReplacement(RecRange,
+ ThisClass->getNameAsString());
+ }
}
}
if (CheckMessageArgumentTypes(ReceiverType, MultiExprArg(Args, NumArgs),
Sel, SelectorLocs,
Method, true,
- SuperLoc.isValid(), LBracLoc, RBracLoc,
+ SuperLoc.isValid(), LBracLoc, RBracLoc,
+ SourceRange(),
ReturnType, VK))
return ExprError();
if (CheckMessageArgumentTypes(ReceiverType, MultiExprArg(Args, NumArgs),
Sel, SelectorLocs, Method,
ClassMessage, SuperLoc.isValid(),
- LBracLoc, RBracLoc, ReturnType, VK))
+ LBracLoc, RBracLoc, RecRange, ReturnType, VK))
return ExprError();
if (Method && !Method->getReturnType()->isVoidType() &&
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// rdar://16263395
+
+@interface NSObject @end
+
+@interface I : NSObject // expected-note 3 {{receiver is instance of class declared here}}
++ (id) ClassMeth;
+- (I*) MethInstPI;
+@end
+
+I* pi;
+
+I* foobar();
+
+@implementation I
+- (id) PrivInstMeth {
+ [ foobar() ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+ // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:5-[[@LINE-2]]:13}:"I
+ [[self MethInstPI] ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+ // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:4-[[@LINE-2]]:21}:"I
+ return [pi ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+ // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"I
+}
++ (id) ClassMeth { return 0; }
+- (I*) MethInstPI { return 0; }
+@end