aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-09-21 18:28:43 +0000
committerTed Kremenek <kremenek@apple.com>2010-09-21 18:28:43 +0000
commit8254aa62d9189395be1eed61194cd4b5ee6cb4a2 (patch)
tree13c8c8e138ef801959ab86518532bc67b86877c7 /lib/Sema/SemaObjCProperty.cpp
parent6f942b2cabf32b96f9901b889d8e44a34e0e7c62 (diff)
For ObjCPropertyDecls in class extensions, use the class extension as the lexical DeclContext for newly created
ObjCMethodDecls. Further, use the location of the new property declaration as the location of new ObjCMethodDecls (if they didn't previously exist). This fixes more of the issues reported in <rdar://problem/7410145>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--lib/Sema/SemaObjCProperty.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 7181d58f7f..a6f251e107 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -188,7 +188,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl,
}
*isOverridingProperty = true;
// Make sure setter decl is synthesized, and added to primary class's list.
- ProcessPropertyDecl(PIDecl, CCPrimary);
+ ProcessPropertyDecl(PIDecl, CCPrimary, PDecl, CDecl);
return 0;
}
@@ -1061,7 +1061,10 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl,
/// appropriate lookup tables. FIXME: Should reconsider if adding synthesized
/// methods is the "right" thing to do.
void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
- ObjCContainerDecl *CD) {
+ ObjCContainerDecl *CD,
+ ObjCPropertyDecl *redeclaredProperty,
+ ObjCContainerDecl *lexicalDC) {
+
ObjCMethodDecl *GetterMethod, *SetterMethod;
GetterMethod = CD->getInstanceMethod(property->getGetterName());
@@ -1123,19 +1126,22 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
// No instance method of same name as property setter name was found.
// Declare a setter method and add it to the list of methods
// for this class.
- SetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
- property->getLocation(),
- property->getSetterName(),
- Context.VoidTy, 0, CD, true, false, true,
- false,
+ SourceLocation Loc = redeclaredProperty ?
+ redeclaredProperty->getLocation() :
+ property->getLocation();
+
+ SetterMethod =
+ ObjCMethodDecl::Create(Context, Loc, Loc,
+ property->getSetterName(), Context.VoidTy, 0,
+ CD, true, false, true, false,
(property->getPropertyImplementation() ==
ObjCPropertyDecl::Optional) ?
- ObjCMethodDecl::Optional :
- ObjCMethodDecl::Required);
+ ObjCMethodDecl::Optional :
+ ObjCMethodDecl::Required);
+
// Invent the arguments for the setter. We don't bother making a
// nice name for the argument.
- ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterMethod,
- property->getLocation(),
+ ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterMethod, Loc,
property->getIdentifier(),
property->getType(),
/*TInfo=*/0,
@@ -1146,7 +1152,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
CD->addDecl(SetterMethod);
// FIXME: Eventually this shouldn't be needed, as the lexical context
// and the real context should be the same.
- if (DeclContext *lexicalDC = property->getLexicalDeclContext())
+ if (lexicalDC)
SetterMethod->setLexicalDeclContext(lexicalDC);
} else
// A user declared setter will be synthesize when @synthesize of