diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-05-07 17:43:59 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-05-07 17:43:59 +0000 |
commit | ec6e4c809680d37c75702563a26f9b866a4c16f4 (patch) | |
tree | 6ec5838f53a0101443cfb8e8e26e59b7e062a5d6 /clang/lib/AST/DeclObjC.cpp | |
parent | 89bd0fc27dd5cac99c71e186f51f4bcf9b1eab9b (diff) | |
download | bcm5719-llvm-ec6e4c809680d37c75702563a26f9b866a4c16f4.tar.gz bcm5719-llvm-ec6e4c809680d37c75702563a26f9b866a4c16f4.zip |
This patch introduces declaration of getter methods for ObjC2's
properties. Couple of property tests will fail with this patch.
Will fix them next.
llvm-svn: 50818
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 0cb777d8deb..3c89a6aa7df 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -270,6 +270,36 @@ void ObjCInterfaceDecl::mergeProperties(ObjCPropertyDecl **Properties, } } +/// addPropertyMethods - Goes through list of properties declared in this class +/// and builds setter/getter method declartions depending on the setter/getter +/// attributes of the property. +/// +void ObjCInterfaceDecl::addPropertyMethods( + ASTContext &Context, + ObjCPropertyDecl *property, + llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) { + // Find the default getter and if one not found, add one. + ObjCMethodDecl *GetterDecl = getInstanceMethod(property->getGetterName()); + if (GetterDecl) { + // An instance method with same name as property getter name found. + property->setGetterMethodDecl(GetterDecl); + } + else { + // No instance method of same name as property getter name was found. + // Declare a getter method and add it to the list of methods + // for this class. + QualType resultDeclType = property->getType(); + ObjCMethodDecl* ObjCMethod = + ObjCMethodDecl::Create(Context, property->getLocation(), + property->getLocation(), + property->getGetterName(), resultDeclType, + this, 0, + true, false, ObjCMethodDecl::Required); + property->setGetterMethodDecl(ObjCMethod); + insMethods.push_back(ObjCMethod); + } +} + /// addProperties - Insert property declaration AST nodes into /// ObjCProtocolDecl's PropertyDecl field. /// |