diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-23 01:26:30 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-23 01:26:30 +0000 |
commit | 0e5ad255729ee86b8ed57e659029008984517cde (patch) | |
tree | 38d7c5953850f1177aa34570fa451ec2ecc2154c /lib/AST/DeclObjC.cpp | |
parent | 133a6aab12ae3706e83da7c1f2fb15316efc12c2 (diff) |
More support for ivars in class extension.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96850 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 131e098d04..8decafa35e 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -202,6 +202,17 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( setProtocolList(ProtocolRefs.data(), NumProtoRefs, ProtocolLocs.data(), C); } +/// getClassExtension - Find class extension of the given class. +// FIXME. can speed it up, if need be. +ObjCCategoryDecl* ObjCInterfaceDecl::getClassExtension() const { + const ObjCInterfaceDecl* ClassDecl = this; + for (ObjCCategoryDecl *CDecl = ClassDecl->getCategoryList(); CDecl; + CDecl = CDecl->getNextClassCategory()) + if (CDecl->IsClassExtension()) + return CDecl; + return 0; +} + ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) { ObjCInterfaceDecl* ClassDecl = this; @@ -210,6 +221,12 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, clsDeclared = ClassDecl; return I; } + if (const ObjCCategoryDecl *CDecl = ClassDecl->getClassExtension()) + if (ObjCIvarDecl *I = CDecl->getIvarDecl(ID)) { + clsDeclared = ClassDecl; + return I; + } + ClassDecl = ClassDecl->getSuperClass(); } return NULL; |