[cfe-commits] r151633 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp tools/libclang/IndexDecl.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Feb 28 09:50:28 PST 2012
Author: akirtzidis
Date: Tue Feb 28 11:50:28 2012
New Revision: 151633
URL: http://llvm.org/viewvc/llvm-project?rev=151633&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/tools/libclang/IndexDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=151633&r1=151632&r2=151633&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Feb 28 11:50:28 2012
@@ -263,7 +263,7 @@
if (!PIDecl) {
// No matching property found in the primary class. Just fall thru
// and add property to continuation class's primary class.
- ObjCPropertyDecl *PDecl =
+ ObjCPropertyDecl *PrimaryPDecl =
CreatePropertyDecl(S, CCPrimary, AtLoc,
FD, GetterSel, SetterSel, isAssign, isReadWrite,
Attributes,AttributesAsWritten, T, MethodImplKind, DC);
@@ -271,11 +271,13 @@
// 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.
// Make sure setter/getters are declared here.
- ProcessPropertyDecl(PDecl, CCPrimary, /* redeclaredProperty = */ 0,
+ ProcessPropertyDecl(PrimaryPDecl, CCPrimary, /* redeclaredProperty = */ 0,
/* lexicalDC = */ CDecl);
+ PDecl->setGetterMethodDecl(PrimaryPDecl->getGetterMethodDecl());
+ PDecl->setSetterMethodDecl(PrimaryPDecl->getSetterMethodDecl());
if (ASTMutationListener *L = Context.getASTMutationListener())
- L->AddedObjCPropertyInClassExtension(PDecl, /*OrigProp=*/0, CDecl);
- return PDecl;
+ L->AddedObjCPropertyInClassExtension(PrimaryPDecl, /*OrigProp=*/0, CDecl);
+ return PrimaryPDecl;
}
if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
bool IncompatibleObjC = false;
@@ -360,6 +362,8 @@
*isOverridingProperty = true;
// Make sure setter decl is synthesized, and added to primary class's list.
ProcessPropertyDecl(PIDecl, CCPrimary, PDecl, CDecl);
+ PDecl->setGetterMethodDecl(PIDecl->getGetterMethodDecl());
+ PDecl->setSetterMethodDecl(PIDecl->getSetterMethodDecl());
if (ASTMutationListener *L = Context.getASTMutationListener())
L->AddedObjCPropertyInClassExtension(PDecl, PIDecl, CDecl);
return 0;
Modified: cfe/trunk/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexDecl.cpp?rev=151633&r1=151632&r2=151633&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexDecl.cpp (original)
+++ cfe/trunk/tools/libclang/IndexDecl.cpp Tue Feb 28 11:50:28 2012
@@ -41,6 +41,24 @@
}
}
+ 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) {
IndexCtx.handleFunction(D);
handleDeclarator(D);
@@ -161,22 +179,22 @@
}
bool VisitObjCMethodDecl(ObjCMethodDecl *D) {
- IndexCtx.handleObjCMethod(D);
- IndexCtx.indexTypeSourceInfo(D->getResultTypeSourceInfo(), D);
- for (ObjCMethodDecl::param_iterator
- I = D->param_begin(), E = D->param_end(); I != E; ++I)
- handleDeclarator(*I, D);
+ // Methods associated with a property, even user-declared ones, are
+ // handled when we handle the property.
+ if (D->isSynthesized())
+ return true;
- if (D->isThisDeclarationADefinition()) {
- const Stmt *Body = D->getBody();
- if (Body) {
- IndexCtx.indexBody(Body, D, D);
- }
- }
+ handleObjCMethod(D);
return true;
}
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.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
return true;
More information about the cfe-commits
mailing list