зеркало из https://github.com/microsoft/clang-1.git
move the @implementation ivar list to being an ObjCList, which prevents
it from being leaked, among other things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65150 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f259f0fa62
Коммит
7a21bd046f
|
@ -861,9 +861,8 @@ class ObjCImplementationDecl : public Decl, public DeclContext {
|
|||
/// Implementation Class's super class.
|
||||
ObjCInterfaceDecl *SuperClass;
|
||||
|
||||
/// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
|
||||
ObjCIvarDecl **Ivars; // Null if not specified
|
||||
unsigned NumIvars; // 0 if none.
|
||||
/// Instance variables declared in the @implementation.
|
||||
ObjCList<ObjCIvarDecl> IVars;
|
||||
|
||||
/// implemented instance methods
|
||||
llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
|
||||
|
@ -880,18 +879,20 @@ class ObjCImplementationDecl : public Decl, public DeclContext {
|
|||
ObjCInterfaceDecl *classInterface,
|
||||
ObjCInterfaceDecl *superDecl)
|
||||
: Decl(ObjCImplementation, DC, L), DeclContext(ObjCImplementation),
|
||||
ClassInterface(classInterface), SuperClass(superDecl),
|
||||
Ivars(0), NumIvars(0) {}
|
||||
ClassInterface(classInterface), SuperClass(superDecl){}
|
||||
public:
|
||||
static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
ObjCInterfaceDecl *classInterface,
|
||||
ObjCInterfaceDecl *superDecl);
|
||||
|
||||
/// Destroy - Call destructors and release memory.
|
||||
virtual void Destroy(ASTContext& C);
|
||||
|
||||
void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num) {
|
||||
IVars.set(InArray, Num);
|
||||
}
|
||||
|
||||
void ObjCAddInstanceVariablesToClassImpl(ObjCIvarDecl **ivars,
|
||||
unsigned numIvars);
|
||||
|
||||
void addInstanceMethod(ObjCMethodDecl *method) {
|
||||
InstanceMethods.push_back(method);
|
||||
}
|
||||
|
@ -963,11 +964,11 @@ public:
|
|||
return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
|
||||
}
|
||||
|
||||
typedef ObjCIvarDecl * const *ivar_iterator;
|
||||
ivar_iterator ivar_begin() const { return Ivars; }
|
||||
ivar_iterator ivar_end() const { return Ivars+NumIvars; }
|
||||
unsigned ivar_size() const { return NumIvars; }
|
||||
bool ivar_empty() const { return NumIvars == 0; }
|
||||
typedef ObjCList<ObjCIvarDecl>::iterator ivar_iterator;
|
||||
ivar_iterator ivar_begin() const { return IVars.begin(); }
|
||||
ivar_iterator ivar_end() const { return IVars.end(); }
|
||||
unsigned ivar_size() const { return IVars.size(); }
|
||||
bool ivar_empty() const { return IVars.empty(); }
|
||||
|
||||
static bool classof(const Decl *D) {
|
||||
return D->getKind() == ObjCImplementation;
|
||||
|
|
|
@ -175,6 +175,12 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
|
|||
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
|
||||
}
|
||||
|
||||
/// Destroy - Call destructors and release memory.
|
||||
void ObjCImplementationDecl::Destroy(ASTContext& C) {
|
||||
IVars.clear();
|
||||
}
|
||||
|
||||
|
||||
ObjCCompatibleAliasDecl *
|
||||
ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
|
@ -250,18 +256,6 @@ FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context,
|
|||
return MemberDecl;
|
||||
}
|
||||
|
||||
/// ObjCAddInstanceVariablesToClassImpl - Checks for correctness of Instance
|
||||
/// Variables (Ivars) relative to what declared in @implementation;s class.
|
||||
/// Ivars into ObjCImplementationDecl's fields.
|
||||
///
|
||||
void ObjCImplementationDecl::ObjCAddInstanceVariablesToClassImpl(
|
||||
ObjCIvarDecl **ivars, unsigned numIvars) {
|
||||
NumIvars = numIvars;
|
||||
if (numIvars) {
|
||||
Ivars = new ObjCIvarDecl*[numIvars];
|
||||
memcpy(Ivars, ivars, numIvars*sizeof(ObjCIvarDecl*));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the local instance method declared in this interface.
|
||||
// FIXME: handle overloading, instance & class methods can have the same name.
|
||||
|
|
|
@ -3458,13 +3458,10 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagD,
|
|||
|
||||
}
|
||||
|
||||
// FIXME: Chain fielddecls together.
|
||||
FieldDecl *NewFD;
|
||||
|
||||
NewFD = FieldDecl::Create(Context, Record,
|
||||
Loc, II, T, BitWidth,
|
||||
D.getDeclSpec().getStorageClassSpec() ==
|
||||
DeclSpec::SCS_mutable);
|
||||
FieldDecl *NewFD = FieldDecl::Create(Context, Record,
|
||||
Loc, II, T, BitWidth,
|
||||
D.getDeclSpec().getStorageClassSpec() ==
|
||||
DeclSpec::SCS_mutable);
|
||||
|
||||
if (II) {
|
||||
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
|
||||
|
@ -3710,7 +3707,7 @@ void Sema::ActOnFields(Scope* S,
|
|||
else if (ObjCImplementationDecl *IMPDecl =
|
||||
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
|
||||
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
|
||||
IMPDecl->ObjCAddInstanceVariablesToClassImpl(ClsFields, RecFields.size());
|
||||
IMPDecl->setIVarList(ClsFields, RecFields.size());
|
||||
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче