diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-05-18 21:09:07 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-05-18 21:09:07 +0000 |
commit | 23173d7f029f430611caceea72ae61ba6b80af1c (patch) | |
tree | a5f488b4837ef504fdf4f80c4e867694a2b2cb1c /lib/Sema/SemaObjCProperty.cpp | |
parent | bf1ee342a298d5845c18ef28b2d5b921a1a291d0 (diff) |
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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104055 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 69a338224e..453ea25859 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/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 |