summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-27 02:09:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-27 02:09:39 +0000
commite7ecbc539ed3c27b993b552b90483a45e054c813 (patch)
tree8051b33145f704aeb6175dda6e6e75c8db010b42 /clang/lib
parent912c28444f7e5da23f1474e3026747a83d6b1d02 (diff)
downloadbcm5719-llvm-e7ecbc539ed3c27b993b552b90483a45e054c813.tar.gz
bcm5719-llvm-e7ecbc539ed3c27b993b552b90483a45e054c813.zip
Add addPropertyMethods implementations for
ObjC{Category,Protocol}Decl. - No functionality change. llvm-svn: 55404
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclObjC.cpp69
1 files changed, 57 insertions, 12 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index e74e21dbbca..8fb4406eff1 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -402,14 +402,28 @@ 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) {
+static void
+addPropertyMethods(Decl *D,
+ ASTContext &Context,
+ ObjCPropertyDecl *property,
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+ ObjCMethodDecl *GetterDecl, *SetterDecl;
+
+ if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(D)) {
+ GetterDecl = OID->getInstanceMethod(property->getGetterName());
+ if (!property->isReadOnly())
+ SetterDecl = OID->getInstanceMethod(property->getSetterName());
+ } else if (ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(D)) {
+ GetterDecl = OCD->getInstanceMethod(property->getGetterName());
+ if (!property->isReadOnly())
+ SetterDecl = OCD->getInstanceMethod(property->getSetterName());
+ } else {
+ ObjCProtocolDecl *OPD = cast<ObjCProtocolDecl>(D);
+ GetterDecl = OPD->getInstanceMethod(property->getGetterName());
+ if (!property->isReadOnly())
+ SetterDecl = OPD->getInstanceMethod(property->getSetterName());
+ }
+
// FIXME: The synthesized property we set here is misleading. We
// almost always synthesize these methods unless the user explicitly
// provided prototypes (which is odd, but allowed). Sema should be
@@ -417,7 +431,6 @@ void ObjCInterfaceDecl::addPropertyMethods(
// it is not currently).
// Find the default getter and if one not found, add one.
- ObjCMethodDecl *GetterDecl = getInstanceMethod(property->getGetterName());
if (!GetterDecl) {
// No instance method of same name as property getter name was found.
// Declare a getter method and add it to the list of methods
@@ -427,7 +440,7 @@ void ObjCInterfaceDecl::addPropertyMethods(
property->getLocation(),
property->getGetterName(),
property->getType(),
- this,
+ D,
true, false, true, ObjCMethodDecl::Required);
insMethods.push_back(GetterDecl);
}
@@ -438,7 +451,6 @@ void ObjCInterfaceDecl::addPropertyMethods(
return;
// Find the default setter and if one not found, add one.
- ObjCMethodDecl *SetterDecl = getInstanceMethod(property->getSetterName());
if (!SetterDecl) {
// No instance method of same name as property setter name was found.
// Declare a setter method and add it to the list of methods
@@ -448,7 +460,7 @@ void ObjCInterfaceDecl::addPropertyMethods(
property->getLocation(),
property->getSetterName(),
Context.VoidTy,
- this,
+ D,
true, false, true, ObjCMethodDecl::Required);
insMethods.push_back(SetterDecl);
@@ -466,6 +478,39 @@ void ObjCInterfaceDecl::addPropertyMethods(
property->setSetterMethodDecl(SetterDecl);
}
+/// 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) {
+ ::addPropertyMethods(this, Context, property, insMethods);
+}
+
+/// 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 ObjCCategoryDecl::addPropertyMethods(
+ ASTContext &Context,
+ ObjCPropertyDecl *property,
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+ ::addPropertyMethods(this, Context, property, insMethods);
+}
+
+/// 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 ObjCProtocolDecl::addPropertyMethods(
+ ASTContext &Context,
+ ObjCPropertyDecl *property,
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+ ::addPropertyMethods(this, Context, property, insMethods);
+}
+
/// addProperties - Insert property declaration AST nodes into
/// ObjCProtocolDecl's PropertyDecl field.
///
OpenPOWER on IntegriCloud