diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-20 21:35:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-20 21:35:13 +0000 |
commit | 38af2deb27cdfa1a95bde96e30dab15dce53fcef (patch) | |
tree | 59ea0e3b21832285ca2a9cb52c1da38f32813790 /lib | |
parent | 11e1e1af2641affb378080a4f3d1a30da1cad082 (diff) |
add plumbing to get ASTContext& down to allocation/deallocation points in ObjCList,
but don't start using it yet. Renamed some methods to be more consistent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 48 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 23 |
3 files changed, 44 insertions, 33 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 5a3c730a76..4e22ebea16 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -20,13 +20,13 @@ using namespace clang; // ObjCListBase //===----------------------------------------------------------------------===// -void ObjCListBase::Destroy() { +void ObjCListBase::Destroy(ASTContext &Ctx) { delete[] List; NumElts = 0; List = 0; } -void ObjCListBase::set(void *const* InList, unsigned Elts) { +void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) { assert(List == 0 && "Elements already set!"); if (Elts == 0) return; // Setting to an empty list is a noop. @@ -206,14 +206,14 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, isVariadic, isSynthesized, impControl); } -void ObjCMethodDecl::Destroy(ASTContext& C) { +void ObjCMethodDecl::Destroy(ASTContext &C) { if (Body) Body->Destroy(C); if (SelfDecl) SelfDecl->Destroy(C); for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I) if (*I) (*I)->Destroy(C); - ParamInfo.Destroy(); + ParamInfo.Destroy(C); Decl::Destroy(C); } @@ -300,7 +300,7 @@ void ObjCInterfaceDecl::Destroy(ASTContext &C) { for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I) if (*I) (*I)->Destroy(C); - IVars.Destroy(); + IVars.Destroy(C); // FIXME: CategoryList? // FIXME: Because there is no clear ownership @@ -377,7 +377,7 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, } void ObjCProtocolDecl::Destroy(ASTContext &C) { - ReferencedProtocols.Destroy(); + ReferencedProtocols.Destroy(C); ObjCContainerDecl::Destroy(C); } @@ -413,11 +413,19 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) { // ObjCClassDecl //===----------------------------------------------------------------------===// +ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L, + ObjCInterfaceDecl *const *Elts, unsigned nElts, + ASTContext &C) + : Decl(ObjCClass, DC, L) { + ForwardDecls.set(Elts, nElts, C); +} + + ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ObjCInterfaceDecl *const *Elts, unsigned nElts) { - return new (C) ObjCClassDecl(DC, L, Elts, nElts); + return new (C) ObjCClassDecl(DC, L, Elts, nElts, C); } void ObjCClassDecl::Destroy(ASTContext &C) { @@ -430,7 +438,7 @@ void ObjCClassDecl::Destroy(ASTContext &C) { // obviating this problem. Because of this situation, referenced // ObjCInterfaceDecls are destroyed in ~TranslationUnit. - ForwardDecls.Destroy(); + ForwardDecls.Destroy(C); Decl::Destroy(C); } @@ -438,23 +446,25 @@ void ObjCClassDecl::Destroy(ASTContext &C) { // ObjCForwardProtocolDecl //===----------------------------------------------------------------------===// +ObjCForwardProtocolDecl:: +ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, + ObjCProtocolDecl *const *Elts, unsigned nElts, + ASTContext &C) +: Decl(ObjCForwardProtocol, DC, L) { + ReferencedProtocols.set(Elts, nElts, C); +} + + ObjCForwardProtocolDecl * ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ObjCProtocolDecl *const *Elts, unsigned NumElts) { - return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts); -} - -ObjCForwardProtocolDecl:: -ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L, - ObjCProtocolDecl *const *Elts, unsigned nElts) - : Decl(ObjCForwardProtocol, DC, L) { - ReferencedProtocols.set(Elts, nElts); + return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, C); } void ObjCForwardProtocolDecl::Destroy(ASTContext &C) { - ReferencedProtocols.Destroy(); + ReferencedProtocols.Destroy(C); Decl::Destroy(C); } @@ -543,8 +553,8 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, } /// Destroy - Call destructors and release memory. -void ObjCImplementationDecl::Destroy(ASTContext& C) { - IVars.Destroy(); +void ObjCImplementationDecl::Destroy(ASTContext &C) { + IVars.Destroy(C); Decl::Destroy(C); } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d91c2c1a19..c7f37fc286 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3688,7 +3688,9 @@ void Sema::ActOnFields(Scope* S, } else { ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(&RecFields[0]); if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl)) { - ID->addInstanceVariablesToClass(ClsFields, RecFields.size(), RBrac); + ID->setIVarList(ClsFields, RecFields.size(), Context); + ID->setLocEnd(RBrac); + // Must enforce the rule that ivars in the base classes may not be // duplicates. if (ID->getSuperClass()) { @@ -3707,7 +3709,7 @@ void Sema::ActOnFields(Scope* S, else if (ObjCImplementationDecl *IMPDecl = dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl"); - IMPDecl->setIVarList(ClsFields, RecFields.size()); + IMPDecl->setIVarList(ClsFields, RecFields.size(), Context); CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac); } } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 65cd4b4e54..db432c8aef 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -152,7 +152,8 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, /// Check then save referenced protocols. if (NumProtoRefs) { - IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); + IDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs, + Context); IDecl->setLocEnd(EndProtoLoc); } @@ -245,7 +246,7 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, ProcessDeclAttributeList(PDecl, AttrList); if (NumProtoRefs) { /// Check then save referenced protocols. - PDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); + PDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context); PDecl->setLocEnd(EndProtoLoc); } @@ -509,7 +510,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, CDecl->insertNextClassCategory(); if (NumProtoRefs) { - CDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs); + CDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context); CDecl->setLocEnd(EndProtoLoc); } @@ -634,7 +635,8 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, /// (legacy objective-c @implementation decl without an @interface decl). /// Add implementations's ivar to the synthesize class's ivar list. if (IDecl->ImplicitInterfaceDecl()) { - IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace); + IDecl->setIVarList(ivars, numIvars, Context); + IDecl->setLocEnd(RBrace); return; } // If implementation has empty ivar list, just return. @@ -1166,7 +1168,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, property->getType(), VarDecl::None, 0); - SetterMethod->setMethodParams(&Argument, 1); + SetterMethod->setMethodParams(&Argument, 1, Context); CD->addDecl(SetterMethod); } else // A user declared setter will be synthesize when @synthesize of @@ -1395,7 +1397,7 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( Params.push_back(Param); } - ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs()); + ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs(), Context); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); const ObjCMethodDecl *PrevMethod = 0; @@ -1560,14 +1562,11 @@ Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, ICDecl, true, false, true, ObjCMethodDecl::Required); - ParmVarDecl *Argument = ParmVarDecl::Create(Context, - SetterDecl, + ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterDecl, SourceLocation(), FD.D.getIdentifier(), - T, - VarDecl::None, - 0); - SetterDecl->setMethodParams(&Argument, 1); + T, VarDecl::None, 0); + SetterDecl->setMethodParams(&Argument, 1, Context); PIDecl->setSetterMethodDecl(SetterDecl); } else |