diff options
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. /// |

