From ab5d7aef727dc67949209a4b79861cc581af48a8 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 2 Apr 2010 19:44:54 +0000 Subject: [PATCH] Sema/Obj-C: Narrow type, and simplify. llvm-svn: 100210 --- clang/lib/Sema/SemaObjCProperty.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index f815068fac2d..52b9bcf86c8d 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -281,7 +281,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, DeclPtrTy ClassCatImpDecl, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar) { - Decl *ClassImpDecl = ClassCatImpDecl.getAs(); + ObjCContainerDecl *ClassImpDecl = ClassCatImpDecl.getAs(); // Make sure we have a context for the property implementation declaration. if (!ClassImpDecl) { Diag(AtLoc, diag::error_missing_property_context); @@ -353,14 +353,11 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, ObjCInterfaceDecl *ClassDeclared; Ivar = IDecl->lookupInstanceVariable(PropertyIvar, ClassDeclared); if (!Ivar) { - DeclContext *EnclosingContext = cast_or_null(ClassImpDecl); - assert(EnclosingContext && - "null DeclContext for synthesized ivar - ActOnPropertyImplDecl"); - Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, PropertyLoc, + Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl, PropertyLoc, PropertyIvar, PropType, /*Dinfo=*/0, ObjCIvarDecl::Public, (Expr *)0); - EnclosingContext->addDecl(Ivar); + ClassImpDecl->addDecl(Ivar); IDecl->makeDeclVisibleInContext(Ivar, false); property->setPropertyIvarDecl(Ivar); @@ -1072,15 +1069,10 @@ Sema::SynthesizeNewPropertyIvar(ObjCInterfaceDecl *IDecl, ObjCIvarDecl *Ivar = 0; ObjCPropertyDecl *Prop = LookupPropertyDecl(IDecl, NameII); if (Prop && !Prop->isInvalidDecl()) { - DeclContext *EnclosingContext = cast_or_null(IDecl); QualType PropType = Context.getCanonicalType(Prop->getType()); - assert(EnclosingContext && - "null DeclContext for synthesized ivar - SynthesizeNewPropertyIvar"); - Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, - Prop->getLocation(), - NameII, PropType, /*Dinfo=*/0, - ObjCIvarDecl::Public, - (Expr *)0); + Ivar = ObjCIvarDecl::Create(Context, IDecl, Prop->getLocation(), NameII, + PropType, /*Dinfo=*/0, + ObjCIvarDecl::Public, (Expr *)0); Ivar->setLexicalDeclContext(IDecl); IDecl->addDecl(Ivar); Prop->setPropertyIvarDecl(Ivar);