summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-18 21:09:07 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-18 21:09:07 +0000
commit49be9e0819a5c05bf82695be28e21f71b8adda3e (patch)
tree064da43255fddbb14eb3e7b521743ce95ab596f6 /clang/lib/Sema
parent6338d1593965bb0bd34ba97ba2e03a9a5be24b0f (diff)
downloadbcm5719-llvm-49be9e0819a5c05bf82695be28e21f71b8adda3e.tar.gz
bcm5719-llvm-49be9e0819a5c05bf82695be28e21f71b8adda3e.zip
Teach CursorVisitor about duplicate ObjCPropertyDecls that can arise because of a current
design limitation in how we handle Objective-C class extensions. This was causing the CursorVisitor to essentially visit an @property twice (once in the @interface, the other in the class extension). Fixes <rdar://problem/7410145>. llvm-svn: 104055
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/Sema.h3
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp19
2 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 975516ff9a3..432e9e701b4 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -1597,7 +1597,8 @@ public:
const bool isAssign,
const bool isReadWrite,
const unsigned Attributes, QualType T,
- tok::ObjCKeywordKind MethodImplKind);
+ tok::ObjCKeywordKind MethodImplKind,
+ DeclContext *lexicalDC = 0);
/// AtomicPropertySetterGetterRules - This routine enforces the rule (via
/// warning) when atomic property has one but not the other user-declared
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 69a338224ec..453ea25859e 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -121,7 +121,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl,
ObjCPropertyDecl *PDecl =
CreatePropertyDecl(S, CCPrimary, AtLoc,
FD, GetterSel, SetterSel, isAssign, isReadWrite,
- Attributes, T, MethodImplKind);
+ Attributes, T, MethodImplKind, DC);
// A case of continuation class adding a new property in the class. This
// is not what it was meant for. However, gcc supports it and so should we.
@@ -191,7 +191,8 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
const bool isReadWrite,
const unsigned Attributes,
QualType T,
- tok::ObjCKeywordKind MethodImplKind){
+ tok::ObjCKeywordKind MethodImplKind,
+ DeclContext *lexicalDC){
IdentifierInfo *PropertyId = FD.D.getIdentifier();
@@ -222,8 +223,11 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
Diag(prevDecl->getLocation(), diag::note_property_declare);
PDecl->setInvalidDecl();
}
- else
+ else {
DC->addDecl(PDecl);
+ if (lexicalDC)
+ PDecl->setLexicalDeclContext(lexicalDC);
+ }
if (T->isArrayType() || T->isFunctionType()) {
Diag(AtLoc, diag::err_property_type) << T;
@@ -1064,6 +1068,11 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
ObjCMethodDecl::Optional :
ObjCMethodDecl::Required);
CD->addDecl(GetterMethod);
+ // FIXME: Eventually this shouldn't be needed, as the lexical context
+ // and the real context should be the same.
+ if (DeclContext *lexicalDC = property->getLexicalDeclContext())
+ GetterMethod->setLexicalDeclContext(lexicalDC);
+
} else
// A user declared getter will be synthesize when @synthesize of
// the property with the same name is seen in the @implementation
@@ -1097,6 +1106,10 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
0);
SetterMethod->setMethodParams(Context, &Argument, 1, 1);
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())
+ SetterMethod->setLexicalDeclContext(lexicalDC);
} else
// A user declared setter will be synthesize when @synthesize of
// the property with the same name is seen in the @implementation
OpenPOWER on IntegriCloud