diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-05-14 23:24:17 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-05-14 23:24:17 +0000 |
commit | 9f00b1d3962147a2fe049b8b45f70680bc12fbc1 (patch) | |
tree | b69b0fffb37e3d242e9a8c70d671926fd45d101f | |
parent | 86a87308f11e7ee7c71ff608aec0cde11aa7df58 (diff) | |
download | clang-9f00b1d3962147a2fe049b8b45f70680bc12fbc1.tar.gz clang-9f00b1d3962147a2fe049b8b45f70680bc12fbc1.tar.bz2 clang-9f00b1d3962147a2fe049b8b45f70680bc12fbc1.tar.xz |
Objective-C [diagnostics] [QOI], when method is not
found for a receiver, note where receiver class
is declaraed (this is most common when receiver is a forward
class). // rdar://3258331
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181847 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 11 | ||||
-rw-r--r-- | test/Analysis/inlining/DynDispatchBifurcate.m | 4 | ||||
-rw-r--r-- | test/Analysis/rdar-6540084.m | 4 | ||||
-rw-r--r-- | test/Modules/objc-categories.m | 1 | ||||
-rw-r--r-- | test/PCH/chain-categories2.m | 1 | ||||
-rw-r--r-- | test/SemaObjC/call-super-2.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/compare-qualified-id.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/conditional-expr.m | 3 | ||||
-rw-r--r-- | test/SemaObjC/error-outof-scope-property-use.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/instancetype.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/message.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/method-not-defined.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/missing-atend-metadata.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/property-5.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/protocol-id-test-1.m | 2 | ||||
-rw-r--r-- | test/SemaObjCXX/instancetype.mm | 2 |
17 files changed, 30 insertions, 16 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index c2728820d4..db4696767a 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -499,6 +499,8 @@ def note_while_in_implementation : Note< "detected while default synthesizing properties in class implementation">; def note_class_declared : Note< "class is declared here">; +def note_receiver_class_declared : Note< + "receiver is object of the class that is declared here">; def note_receiver_is_id : Note< "receiver is treated with 'id' type for purpose of method lookup">; def note_suppressed_class_declare : Note< diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index d37f61ab8a..7c701ea040 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -1221,10 +1221,19 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, else DiagID = isClassMessage ? diag::warn_class_method_not_found : diag::warn_inst_method_not_found; - if (!getLangOpts().DebuggerSupport) + if (!getLangOpts().DebuggerSupport) { Diag(SelLoc, DiagID) << Sel << isClassMessage << SourceRange(SelectorLocs.front(), SelectorLocs.back()); + // Find the class to which we are sending this message. + if (ReceiverType->isObjCObjectPointerType()) { + QualType ClassType = + ReceiverType->getAs<ObjCObjectPointerType>()->getPointeeType(); + if (const ObjCObjectType *ClassTPtr = ClassType->getAs<ObjCObjectType>()) + if (ObjCInterfaceDecl *Class = ClassTPtr->getInterface()) + Diag(Class->getLocation(), diag::note_receiver_class_declared); + } + } // In debuggers, we want to use __unknown_anytype for these // results so that clients can cast them. diff --git a/test/Analysis/inlining/DynDispatchBifurcate.m b/test/Analysis/inlining/DynDispatchBifurcate.m index ab1dfc5ec1..d8af213a06 100644 --- a/test/Analysis/inlining/DynDispatchBifurcate.m +++ b/test/Analysis/inlining/DynDispatchBifurcate.m @@ -181,11 +181,11 @@ int testPropertySynthesized(PublicClass *p) { } // Test definition not available edge case. -@interface DefNotAvailClass : NSObject +@interface DefNotAvailClass : NSObject // expected-note {{receiver is object of the class that is declared here}} @end id testDefNotAvailableInlined(DefNotAvailClass *C) { return [C mem]; // expected-warning {{instance method '-mem' not found}} } id testDefNotAvailable(DefNotAvailClass *C) { return testDefNotAvailableInlined(C); -}
\ No newline at end of file +} diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m index 7070709e57..d93450b5c5 100644 --- a/test/Analysis/rdar-6540084.m +++ b/test/Analysis/rdar-6540084.m @@ -9,13 +9,13 @@ typedef struct _NSZone NSZone; @protocol NSObject - (BOOL)isEqual:(id)object; @end @interface NSObject <NSObject> {} @end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -@class NSArray; +@class NSArray; // expected-note {{receiver is object of the class that is declared here}} @class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; // expected-note{{forward declaration of class here}} @interface FooBazController : NSObject {} @end typedef struct {} TazVersion; @class TazNode; -@interface TazGuttenberg : NSObject {} typedef NSUInteger BugsBunnyType; @end +@interface TazGuttenberg : NSObject {} typedef NSUInteger BugsBunnyType; @end // expected-note {{receiver is object of the class that is declared here}} @interface FooBaz : NSObject {} @property (nonatomic) BugsBunnyType matchType; @property (nonatomic, retain) NSArray *papyrus; @end diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m index 81fb28bafb..07d1760980 100644 --- a/test/Modules/objc-categories.m +++ b/test/Modules/objc-categories.m @@ -10,6 +10,7 @@ // expected-note@Inputs/category_left.h:14 {{previous definition}} // expected-warning@Inputs/category_right.h:11 {{duplicate definition of category}} +// expected-note@Inputs/category_top.h:1 {{receiver is object of the class that is declared here}} @interface Foo(Source) -(void)source; diff --git a/test/PCH/chain-categories2.m b/test/PCH/chain-categories2.m index f230bf9348..8cb06a857c 100644 --- a/test/PCH/chain-categories2.m +++ b/test/PCH/chain-categories2.m @@ -45,6 +45,7 @@ #else //===----------------------------------------------------------------------===// +// expected-note@30 {{receiver is object of the class that is declared here}} void f(I* i) { [i meth]; // expected-warning {{not found}} } diff --git a/test/SemaObjC/call-super-2.m b/test/SemaObjC/call-super-2.m index 3c45a2c732..18a5f09407 100644 --- a/test/SemaObjC/call-super-2.m +++ b/test/SemaObjC/call-super-2.m @@ -14,7 +14,7 @@ id objc_getClass(const char *s); - (int) instance_func0; @end -@interface Derived: Object +@interface Derived: Object // expected-note {{receiver is object of the class that is declared here}} + (int) class_func1; + (int) class_func2; + (int) class_func3; diff --git a/test/SemaObjC/compare-qualified-id.m b/test/SemaObjC/compare-qualified-id.m index 82868f8a16..0b7e106b35 100644 --- a/test/SemaObjC/compare-qualified-id.m +++ b/test/SemaObjC/compare-qualified-id.m @@ -12,7 +12,7 @@ typedef struct _NSZone NSZone; typedef struct {} NSFastEnumerationState; @protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; @end @interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count; @end -@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end +@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end // expected-note {{receiver is object of the class that is declared here}} extern NSString * const NSTaskDidTerminateNotification; @interface XCPropertyExpansionContext : NSObject <NSCopying> { // expected-note {{required for direct or indirect protocol 'NSCopying'}} diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m index ec1305dbe8..083453810c 100644 --- a/test/SemaObjC/conditional-expr.m +++ b/test/SemaObjC/conditional-expr.m @@ -33,7 +33,8 @@ @end // No @interface declaration for DTFilterOutputStream3 -@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}} +@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}} \ + // expected-note {{receiver is object of the class that is declared here}} - (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream { id <DTOutputStreams> nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}} self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream3 *' from incompatible type 'id<DTOutputStreams>'}} diff --git a/test/SemaObjC/error-outof-scope-property-use.m b/test/SemaObjC/error-outof-scope-property-use.m index c69a4055df..023687bbf4 100644 --- a/test/SemaObjC/error-outof-scope-property-use.m +++ b/test/SemaObjC/error-outof-scope-property-use.m @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s // rdar://13178483 -@class NSMutableDictionary; +@class NSMutableDictionary; // expected-note {{receiver is object of the class that is declared here}} @interface LaunchdJobs diff --git a/test/SemaObjC/instancetype.m b/test/SemaObjC/instancetype.m index 8137964737..2374890271 100644 --- a/test/SemaObjC/instancetype.m +++ b/test/SemaObjC/instancetype.m @@ -25,7 +25,7 @@ - (instancetype)otherMethodInProto2; // expected-note{{overridden method returns an instance of its class type}} @end -@interface Subclass1 : Root +@interface Subclass1 : Root // expected-note 4 {{receiver is object of the class that is declared here}} - (instancetype)initSubclass1; - (void)methodOnSubclass1; + (instancetype)allocSubclass1; diff --git a/test/SemaObjC/message.m b/test/SemaObjC/message.m index 40fa102f35..fc75cdbf6e 100644 --- a/test/SemaObjC/message.m +++ b/test/SemaObjC/message.m @@ -107,7 +107,7 @@ void foo5(id p) { // expected-warning {{instance method '-bar' not found}} } -@interface I1 +@interface I1 // expected-note {{receiver is object of the class that is declared here}} -(void)unavail_meth __attribute__((unavailable)); // expected-note {{marked unavailable here}} @end diff --git a/test/SemaObjC/method-not-defined.m b/test/SemaObjC/method-not-defined.m index 22466f7dc3..8f43c5daa7 100644 --- a/test/SemaObjC/method-not-defined.m +++ b/test/SemaObjC/method-not-defined.m @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -@interface Foo +@interface Foo // expected-note {{receiver is object of the class that is declared here}} @end void test() { diff --git a/test/SemaObjC/missing-atend-metadata.m b/test/SemaObjC/missing-atend-metadata.m index f072981dc1..9d0024ac65 100644 --- a/test/SemaObjC/missing-atend-metadata.m +++ b/test/SemaObjC/missing-atend-metadata.m @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s -@interface I0 +@interface I0 // expected-note {{receiver is object of the class that is declared here}} @end @implementation I0 // expected-note {{implementation started here}} diff --git a/test/SemaObjC/property-5.m b/test/SemaObjC/property-5.m index cd7cc2487a..782f77cfea 100644 --- a/test/SemaObjC/property-5.m +++ b/test/SemaObjC/property-5.m @@ -8,7 +8,7 @@ @interface MutableNSData : NSData @end -@interface Base : NSData <P1> +@interface Base : NSData <P1> // expected-note {{receiver is object of the class that is declared here}} @property(readonly) id ref; @property(readonly) Base *p_base; @property(readonly) NSData *nsdata; diff --git a/test/SemaObjC/protocol-id-test-1.m b/test/SemaObjC/protocol-id-test-1.m index 19a4432de6..013f291ad9 100644 --- a/test/SemaObjC/protocol-id-test-1.m +++ b/test/SemaObjC/protocol-id-test-1.m @@ -7,7 +7,7 @@ @protocol P @end -@interface INTF<P> +@interface INTF<P> // expected-note {{receiver is object of the class that is declared here}} - (void)IMeth; @end diff --git a/test/SemaObjCXX/instancetype.mm b/test/SemaObjCXX/instancetype.mm index bbf100ef04..87663b9716 100644 --- a/test/SemaObjCXX/instancetype.mm +++ b/test/SemaObjCXX/instancetype.mm @@ -25,7 +25,7 @@ - (instancetype)otherMethodInProto2; // expected-note{{overridden method returns an instance of its class type}} @end -@interface Subclass1 : Root +@interface Subclass1 : Root // expected-note 4 {{receiver is object of the class that is declared here}} - (instancetype)initSubclass1; - (void)methodOnSubclass1; + (instancetype)allocSubclass1; |