diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-23 00:06:01 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-04-23 00:06:01 +0000 |
commit | 628b96f34e93b643b6e15e75eabb8d96079a7e27 (patch) | |
tree | f165388e7343cdf09821dc06855ec5980e7eb66a /lib/Sema/SemaDeclObjC.cpp | |
parent | 8b9045574329ebac6270dfab7ebadce3179bced1 (diff) |
Patch to build AST for property implementation declarations and
to print declaration from its AST.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 234bead575..61449fc457 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -949,8 +949,9 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, ObjCInterfaceDecl* IDecl = 0; // Find the class or category class where this property must have // a declaration. - if (ObjCImplementationDecl *IC = - dyn_cast<ObjCImplementationDecl>(ClassImpDecl)) { + ObjCImplementationDecl *IC = 0; + ObjCCategoryImplDecl* CatImplClass = 0; + if ((IC = dyn_cast<ObjCImplementationDecl>(ClassImpDecl))) { IDecl = getObjCInterfaceDecl(IC->getIdentifier()); // We always synthesize an interface for an implementation // without an interface decl. So, IDecl is always non-zero. @@ -964,8 +965,7 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, return 0; } } - else if (ObjCCategoryImplDecl* CatImplClass = - dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl)) { + else if ((CatImplClass = dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl))) { if (Synthesize) { Diag(AtLoc, diag::error_synthesize_category_decl); return 0; @@ -994,14 +994,14 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, Diag(AtLoc, diag::error_bad_property_context); return 0; } - + ObjCIvarDecl *Ivar = 0; // Check that we have a valid, previously declared ivar for @synthesize if (Synthesize) { // @synthesize if (!PropertyIvar) PropertyIvar = PropertyId; // Check that this is a previously declared 'ivar' in 'IDecl' interface - ObjCIvarDecl *Ivar = IDecl->FindIvarDeclaration(PropertyIvar); + Ivar = IDecl->FindIvarDeclaration(PropertyIvar); if (!Ivar) { Diag(PropertyLoc, diag::error_missing_property_ivar_decl, PropertyId->getName()); @@ -1020,15 +1020,17 @@ Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc, return 0; } assert (property && "ActOnPropertyImplDecl - property declaration missing"); - // TODO: Build the property implementation AST, pushes it into its - // class/cateogory implementation's vector of property implementations -#if 0 - ObjCCategoryImplDecl *PIDecl = - ObjCCategoryImplDecl::Create(AtLoc, PropertyLoc, property, - Synthesize ? ObjCPropertyImplDecl::OBJC_PR_IMPL_SYNTHSIZE - : ObjCPropertyImplDecl::OBJC_PR_IMPL_DYNAMIC, - PropertyId, PropertyIvar); -#endif - return 0; + ObjCPropertyImplDecl *PIDecl = + ObjCPropertyImplDecl::Create(Context, AtLoc, PropertyLoc, property, + (Synthesize ? + ObjCPropertyImplDecl::OBJC_PR_IMPL_SYNTHSIZE + : ObjCPropertyImplDecl::OBJC_PR_IMPL_DYNAMIC), + Ivar); + if (IC) + IC->addPropertyImplementation(PIDecl); + else + CatImplClass->addPropertyImplementation(PIDecl); + + return PIDecl; } |