diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-16 21:08:45 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-16 21:08:45 +0000 |
commit | 7e7e3872b584bc5e7de7a34c8b9c092032303b72 (patch) | |
tree | dcb84f600af86a0976de97cb47f320b6fc605ebb /lib | |
parent | 678c6358c8d4e368c78629099142397c63c1ee35 (diff) |
This patch adds support for declaraing properties in categories,
just as they are declared in objc classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 16 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 7a99f0f549..c9c5132e29 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -185,8 +185,8 @@ void ObjCInterfaceDecl::addMethods(ObjCMethodDecl **insMethods, AtEndLoc = endLoc; } -/// addMethods - Insert instance and methods declarations into -/// ObjCInterfaceDecl's InsMethods and ClsMethods fields. +/// addProperties - Insert property declaration AST nodes into +/// ObjCInterfaceDecl's PropertyDecl field. /// void ObjCInterfaceDecl::addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties) { @@ -197,6 +197,18 @@ void ObjCInterfaceDecl::addProperties(ObjCPropertyDecl **Properties, memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*)); } +/// addProperties - Insert property declaration AST nodes into +/// ObjCProtocolDecl's PropertyDecl field. +/// +void ObjCCategoryDecl::addProperties(ObjCPropertyDecl **Properties, + unsigned NumProperties) { + if (NumProperties == 0) return; + + NumPropertyDecl = NumProperties; + PropertyDecl = new ObjCPropertyDecl*[NumProperties]; + memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*)); +} + /// addMethods - Insert instance and methods declarations into /// ObjCProtocolDecl's ProtoInsMethods and ProtoClsMethods fields. /// diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index bf9af85a6c..3b6f8eccdb 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -699,6 +699,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl, if (pNum != 0) if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) IDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum); + else + if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(ClassDecl)) + CDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum); for (unsigned i = 0; i < allNum; i++ ) { ObjCMethodDecl *Method = |