diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-19 16:06:57 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-19 16:06:57 +0000 |
commit | 3dbf2f5f00cfc8b25318c119c0d39f4a49d15ebe (patch) | |
tree | 1e9c25554590b456f7da954568b23066272ddebd /lib/Sema/SemaObjCProperty.cpp | |
parent | 00fd773ae92aa452be1bb139a186599b2c43531a (diff) |
objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 9602c2bd5b..a98c2c7d9a 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -74,7 +74,6 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, - Decl *ClassCategory, bool *isOverridingProperty, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC) { @@ -101,12 +100,11 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, !(Attributes & ObjCDeclSpec::DQ_PR_weak))); // Proceed with constructing the ObjCPropertDecls. - ObjCContainerDecl *ClassDecl = - cast<ObjCContainerDecl>(ClassCategory); + ObjCContainerDecl *ClassDecl = cast<ObjCContainerDecl>(CurContext); if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(ClassDecl)) if (CDecl->IsClassExtension()) { - Decl *Res = HandlePropertyInClassExtension(S, CDecl, AtLoc, + Decl *Res = HandlePropertyInClassExtension(S, AtLoc, FD, GetterSel, SetterSel, isAssign, isReadWrite, Attributes, @@ -137,7 +135,7 @@ Decl *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, } Decl * -Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, +Sema::HandlePropertyInClassExtension(Scope *S, SourceLocation AtLoc, FieldDeclarator &FD, Selector GetterSel, Selector SetterSel, const bool isAssign, @@ -146,9 +144,9 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, bool *isOverridingProperty, TypeSourceInfo *T, tok::ObjCKeywordKind MethodImplKind) { - + ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(CurContext); // Diagnose if this property is already in continuation class. - DeclContext *DC = cast<DeclContext>(CDecl); + DeclContext *DC = CurContext; IdentifierInfo *PropertyId = FD.D.getIdentifier(); ObjCInterfaceDecl *CCPrimary = CDecl->getClassInterface(); @@ -235,14 +233,20 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, ProtocolPropertyODS. setPropertyAttributes((ObjCDeclSpec::ObjCPropertyAttributeKind) PIkind); - + // Must re-establish the context from class extension to primary + // class context. + ActOnObjCContainerFinishDefinition(CDecl); + ActOnObjCContainerStartDefinition(CCPrimary); Decl *ProtocolPtrTy = ActOnProperty(S, AtLoc, FD, ProtocolPropertyODS, PIDecl->getGetterName(), PIDecl->getSetterName(), - CCPrimary, isOverridingProperty, + isOverridingProperty, MethodImplKind, /* lexicalDC = */ CDecl); + // restore class extension context. + ActOnObjCContainerFinishDefinition(CCPrimary); + ActOnObjCContainerStartDefinition(CDecl); PIDecl = cast<ObjCPropertyDecl>(ProtocolPtrTy); } PIDecl->makeitReadWriteAttribute(); @@ -507,12 +511,11 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool Synthesize, - Decl *ClassCatImpDecl, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc) { ObjCContainerDecl *ClassImpDecl = - cast_or_null<ObjCContainerDecl>(ClassCatImpDecl); + cast_or_null<ObjCContainerDecl>(CurContext); // Make sure we have a context for the property implementation declaration. if (!ClassImpDecl) { Diag(AtLoc, diag::error_missing_property_context); @@ -1280,7 +1283,7 @@ void Sema::DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl, // Saying that they are located at the @implementation isn't really going // to help users. ActOnPropertyImplDecl(S, SourceLocation(), SourceLocation(), - true,IMPDecl, + true, Prop->getIdentifier(), Prop->getIdentifier(), SourceLocation()); } |