summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-12-02 00:19:12 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-12-02 00:19:12 +0000
commit015a48d1db77214d1ad25d47d374987cc45c6283 (patch)
tree80509c49b4e06fecd89535a0dcfa58dd336c47ef /clang/lib
parent122c515809696bf10751f0d6bdabc37ce5583e3b (diff)
downloadbcm5719-llvm-015a48d1db77214d1ad25d47d374987cc45c6283.tar.gz
bcm5719-llvm-015a48d1db77214d1ad25d47d374987cc45c6283.zip
This patch corrects problem in searching for a setter/getter method for
a property. Previous scheme of seaching in interface's list of methods would not work because this list is not yet constructed. This is in preparation for doing semantic check on viability of setter/getter method declarations. llvm-svn: 60386
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclObjC.cpp42
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp6
2 files changed, 21 insertions, 27 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index e631bac452e..a313acf2007 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -426,24 +426,14 @@ static void
addPropertyMethods(Decl *D,
ASTContext &Context,
ObjCPropertyDecl *property,
- llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
+ llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
ObjCMethodDecl *GetterDecl, *SetterDecl = 0;
-
- 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());
- }
-
+
+ GetterDecl = const_cast<ObjCMethodDecl*>(InsMap[property->getGetterName()]);
+ if (!property->isReadOnly())
+ SetterDecl = const_cast<ObjCMethodDecl*>(InsMap[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
@@ -463,6 +453,7 @@ addPropertyMethods(Decl *D,
D,
true, false, true, ObjCMethodDecl::Required);
insMethods.push_back(GetterDecl);
+ InsMap[property->getGetterName()] = GetterDecl;
}
property->setGetterMethodDecl(GetterDecl);
@@ -483,7 +474,7 @@ addPropertyMethods(Decl *D,
D,
true, false, true, ObjCMethodDecl::Required);
insMethods.push_back(SetterDecl);
-
+ InsMap[property->getSetterName()] = SetterDecl;
// Invent the arguments for the setter. We don't bother making a
// nice name for the argument.
ParmVarDecl *Argument = ParmVarDecl::Create(Context,
@@ -505,8 +496,9 @@ addPropertyMethods(Decl *D,
void ObjCInterfaceDecl::addPropertyMethods(
ASTContext &Context,
ObjCPropertyDecl *property,
- llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
- ::addPropertyMethods(this, Context, property, insMethods);
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
+ llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
+ ::addPropertyMethods(this, Context, property, insMethods, InsMap);
}
/// addPropertyMethods - Goes through list of properties declared in this class
@@ -516,8 +508,9 @@ void ObjCInterfaceDecl::addPropertyMethods(
void ObjCCategoryDecl::addPropertyMethods(
ASTContext &Context,
ObjCPropertyDecl *property,
- llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
- ::addPropertyMethods(this, Context, property, insMethods);
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
+ llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
+ ::addPropertyMethods(this, Context, property, insMethods, InsMap);
}
/// addPropertyMethods - Goes through list of properties declared in this class
@@ -527,8 +520,9 @@ void ObjCCategoryDecl::addPropertyMethods(
void ObjCProtocolDecl::addPropertyMethods(
ASTContext &Context,
ObjCPropertyDecl *property,
- llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
- ::addPropertyMethods(this, Context, property, insMethods);
+ llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods,
+ llvm::DenseMap<Selector, const ObjCMethodDecl*> &InsMap) {
+ ::addPropertyMethods(this, Context, property, insMethods, InsMap);
}
/// addProperties - Insert property declaration AST nodes into
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index b9fc5b719a2..3a78024f90d 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -941,14 +941,14 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
MergeProtocolPropertiesIntoClass(I, I);
for (ObjCInterfaceDecl::classprop_iterator i = I->classprop_begin(),
e = I->classprop_end(); i != e; ++i)
- I->addPropertyMethods(Context, *i, insMethods);
+ I->addPropertyMethods(Context, *i, insMethods, InsMap);
I->addMethods(&insMethods[0], insMethods.size(),
&clsMethods[0], clsMethods.size(), AtEndLoc);
} else if (ObjCProtocolDecl *P = dyn_cast<ObjCProtocolDecl>(ClassDecl)) {
for (ObjCProtocolDecl::classprop_iterator i = P->classprop_begin(),
e = P->classprop_end(); i != e; ++i)
- P->addPropertyMethods(Context, *i, insMethods);
+ P->addPropertyMethods(Context, *i, insMethods, InsMap);
P->addMethods(&insMethods[0], insMethods.size(),
&clsMethods[0], clsMethods.size(), AtEndLoc);
}
@@ -959,7 +959,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
// merge them into category as well?
for (ObjCCategoryDecl::classprop_iterator i = C->classprop_begin(),
e = C->classprop_end(); i != e; ++i)
- C->addPropertyMethods(Context, *i, insMethods);
+ C->addPropertyMethods(Context, *i, insMethods, InsMap);
C->addMethods(&insMethods[0], insMethods.size(),
&clsMethods[0], clsMethods.size(), AtEndLoc);
}
OpenPOWER on IntegriCloud