Skip to content
Snippets Groups Projects
Commit 32b94bed authored by Fariborz Jahanian's avatar Fariborz Jahanian
Browse files

objective-C: when searching for declarations in protocol

list of classes, etc., make sure to look into protocol
definitions. // rdar://12958878


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171777 91177308-0d34-0410-b5e6-96231b3b80d8
parent 3453bf7d
No related branches found
No related tags found
No related merge requests found
......@@ -1352,15 +1352,19 @@ void ObjCProtocolDecl::startDefinition() {
}
void ObjCProtocolDecl::collectPropertiesToImplement(PropertyMap &PM) const {
for (ObjCProtocolDecl::prop_iterator P = prop_begin(),
E = prop_end(); P != E; ++P) {
const ObjCProtocolDecl *PDecl = this;
if (!isThisDeclarationADefinition() && getDefinition())
PDecl = getDefinition();
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
E = PDecl->prop_end(); P != E; ++P) {
ObjCPropertyDecl *Prop = *P;
// Insert into PM if not there already.
PM.insert(std::make_pair(Prop->getIdentifier(), Prop));
}
// Scan through protocol's protocols.
for (ObjCProtocolDecl::protocol_iterator PI = protocol_begin(),
E = protocol_end(); PI != E; ++PI)
for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
E = PDecl->protocol_end(); PI != E; ++PI)
(*PI)->collectPropertiesToImplement(PM);
}
......
......@@ -1593,6 +1593,11 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
NSIDecl = IDecl->lookupInheritedClass(&Context.Idents.get("NSProxy"));
}
// If this is a forward protocol declaration, get its definition.
if (!PDecl->isThisDeclarationADefinition() &&
PDecl->getDefinition())
PDecl = PDecl->getDefinition();
// If a method lookup fails locally we still need to look and see if
// the method was implemented by a base class or an inherited
// protocol. This lookup is slow, but occurs rarely in correct code
......
// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-default-synthesize-properties %s
// rdar://12958878
@interface NSObject @end
@protocol DVTInvalidation
- (void)invalidate; // expected-note {{method 'invalidate' declared here}}
@property int Prop; // expected-note {{property declared here}}
@end
@protocol DVTInvalidation;
@interface IBImageCatalogDocument : NSObject <DVTInvalidation> // expected-note {{required for direct or indirect protocol 'DVTInvalidation'}}
@end
@implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}} \
// expected-warning {{incomplete implementation}} \
// expected-warning {{method 'invalidate' in protocol not implemented}}
@end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment