aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-05-07 17:43:59 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-05-07 17:43:59 +0000
commit33de3f0333ca0b5274291b8d76c86758c0484691 (patch)
treecc2882b4a9ce4aab368d2e1cf18731a1ee95e3c3 /lib/AST/DeclObjC.cpp
parentf4250e24bc339c55de335d50d564542433c5e2d2 (diff)
This patch introduces declaration of getter methods for ObjC2's
properties. Couple of property tests will fail with this patch. Will fix them next. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 0cb777d8de..3c89a6aa7d 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/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.
///