forked from OSchip/llvm-project
[AST] Associate the getter/setter methods to a property of a objc class extension.
[libclang] Index the getter/setter methods of a property of a objc class extension. Fixes rdar://10907597 llvm-svn: 151633
This commit is contained in:
parent
0c52c0f0fd
commit
ceeb19cf18
|
@ -263,7 +263,7 @@ Sema::HandlePropertyInClassExtension(Scope *S,
|
||||||
if (!PIDecl) {
|
if (!PIDecl) {
|
||||||
// No matching property found in the primary class. Just fall thru
|
// No matching property found in the primary class. Just fall thru
|
||||||
// and add property to continuation class's primary class.
|
// and add property to continuation class's primary class.
|
||||||
ObjCPropertyDecl *PDecl =
|
ObjCPropertyDecl *PrimaryPDecl =
|
||||||
CreatePropertyDecl(S, CCPrimary, AtLoc,
|
CreatePropertyDecl(S, CCPrimary, AtLoc,
|
||||||
FD, GetterSel, SetterSel, isAssign, isReadWrite,
|
FD, GetterSel, SetterSel, isAssign, isReadWrite,
|
||||||
Attributes,AttributesAsWritten, T, MethodImplKind, DC);
|
Attributes,AttributesAsWritten, T, MethodImplKind, DC);
|
||||||
|
@ -271,11 +271,13 @@ Sema::HandlePropertyInClassExtension(Scope *S,
|
||||||
// A case of continuation class adding a new property in the class. This
|
// A case of continuation class adding a new property in the class. This
|
||||||
// is not what it was meant for. However, gcc supports it and so should we.
|
// is not what it was meant for. However, gcc supports it and so should we.
|
||||||
// Make sure setter/getters are declared here.
|
// Make sure setter/getters are declared here.
|
||||||
ProcessPropertyDecl(PDecl, CCPrimary, /* redeclaredProperty = */ 0,
|
ProcessPropertyDecl(PrimaryPDecl, CCPrimary, /* redeclaredProperty = */ 0,
|
||||||
/* lexicalDC = */ CDecl);
|
/* lexicalDC = */ CDecl);
|
||||||
|
PDecl->setGetterMethodDecl(PrimaryPDecl->getGetterMethodDecl());
|
||||||
|
PDecl->setSetterMethodDecl(PrimaryPDecl->getSetterMethodDecl());
|
||||||
if (ASTMutationListener *L = Context.getASTMutationListener())
|
if (ASTMutationListener *L = Context.getASTMutationListener())
|
||||||
L->AddedObjCPropertyInClassExtension(PDecl, /*OrigProp=*/0, CDecl);
|
L->AddedObjCPropertyInClassExtension(PrimaryPDecl, /*OrigProp=*/0, CDecl);
|
||||||
return PDecl;
|
return PrimaryPDecl;
|
||||||
}
|
}
|
||||||
if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
|
if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
|
||||||
bool IncompatibleObjC = false;
|
bool IncompatibleObjC = false;
|
||||||
|
@ -360,6 +362,8 @@ Sema::HandlePropertyInClassExtension(Scope *S,
|
||||||
*isOverridingProperty = true;
|
*isOverridingProperty = true;
|
||||||
// Make sure setter decl is synthesized, and added to primary class's list.
|
// Make sure setter decl is synthesized, and added to primary class's list.
|
||||||
ProcessPropertyDecl(PIDecl, CCPrimary, PDecl, CDecl);
|
ProcessPropertyDecl(PIDecl, CCPrimary, PDecl, CDecl);
|
||||||
|
PDecl->setGetterMethodDecl(PIDecl->getGetterMethodDecl());
|
||||||
|
PDecl->setSetterMethodDecl(PIDecl->getSetterMethodDecl());
|
||||||
if (ASTMutationListener *L = Context.getASTMutationListener())
|
if (ASTMutationListener *L = Context.getASTMutationListener())
|
||||||
L->AddedObjCPropertyInClassExtension(PDecl, PIDecl, CDecl);
|
L->AddedObjCPropertyInClassExtension(PDecl, PIDecl, CDecl);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -41,6 +41,24 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleObjCMethod(ObjCMethodDecl *D) {
|
||||||
|
IndexCtx.handleObjCMethod(D);
|
||||||
|
if (D->isImplicit())
|
||||||
|
return;
|
||||||
|
|
||||||
|
IndexCtx.indexTypeSourceInfo(D->getResultTypeSourceInfo(), D);
|
||||||
|
for (ObjCMethodDecl::param_iterator
|
||||||
|
I = D->param_begin(), E = D->param_end(); I != E; ++I)
|
||||||
|
handleDeclarator(*I, D);
|
||||||
|
|
||||||
|
if (D->isThisDeclarationADefinition()) {
|
||||||
|
const Stmt *Body = D->getBody();
|
||||||
|
if (Body) {
|
||||||
|
IndexCtx.indexBody(Body, D, D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool VisitFunctionDecl(FunctionDecl *D) {
|
bool VisitFunctionDecl(FunctionDecl *D) {
|
||||||
IndexCtx.handleFunction(D);
|
IndexCtx.handleFunction(D);
|
||||||
handleDeclarator(D);
|
handleDeclarator(D);
|
||||||
|
@ -161,22 +179,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitObjCMethodDecl(ObjCMethodDecl *D) {
|
bool VisitObjCMethodDecl(ObjCMethodDecl *D) {
|
||||||
IndexCtx.handleObjCMethod(D);
|
// Methods associated with a property, even user-declared ones, are
|
||||||
IndexCtx.indexTypeSourceInfo(D->getResultTypeSourceInfo(), D);
|
// handled when we handle the property.
|
||||||
for (ObjCMethodDecl::param_iterator
|
if (D->isSynthesized())
|
||||||
I = D->param_begin(), E = D->param_end(); I != E; ++I)
|
return true;
|
||||||
handleDeclarator(*I, D);
|
|
||||||
|
|
||||||
if (D->isThisDeclarationADefinition()) {
|
handleObjCMethod(D);
|
||||||
const Stmt *Body = D->getBody();
|
|
||||||
if (Body) {
|
|
||||||
IndexCtx.indexBody(Body, D, D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
|
bool VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
|
||||||
|
if (ObjCMethodDecl *MD = D->getGetterMethodDecl())
|
||||||
|
if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
|
||||||
|
handleObjCMethod(MD);
|
||||||
|
if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
|
||||||
|
if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
|
||||||
|
handleObjCMethod(MD);
|
||||||
IndexCtx.handleObjCProperty(D);
|
IndexCtx.handleObjCProperty(D);
|
||||||
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
|
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue