зеркало из 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.
|
/// Implementation Class's super class.
|
||||||
ObjCInterfaceDecl *SuperClass;
|
ObjCInterfaceDecl *SuperClass;
|
||||||
|
|
||||||
/// Optional Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
|
/// Instance variables declared in the @implementation.
|
||||||
ObjCIvarDecl **Ivars; // Null if not specified
|
ObjCList<ObjCIvarDecl> IVars;
|
||||||
unsigned NumIvars; // 0 if none.
|
|
||||||
|
|
||||||
/// implemented instance methods
|
/// implemented instance methods
|
||||||
llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
|
llvm::SmallVector<ObjCMethodDecl*, 32> InstanceMethods;
|
||||||
|
@ -880,17 +879,19 @@ class ObjCImplementationDecl : public Decl, public DeclContext {
|
||||||
ObjCInterfaceDecl *classInterface,
|
ObjCInterfaceDecl *classInterface,
|
||||||
ObjCInterfaceDecl *superDecl)
|
ObjCInterfaceDecl *superDecl)
|
||||||
: Decl(ObjCImplementation, DC, L), DeclContext(ObjCImplementation),
|
: Decl(ObjCImplementation, DC, L), DeclContext(ObjCImplementation),
|
||||||
ClassInterface(classInterface), SuperClass(superDecl),
|
ClassInterface(classInterface), SuperClass(superDecl){}
|
||||||
Ivars(0), NumIvars(0) {}
|
|
||||||
public:
|
public:
|
||||||
static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
|
static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
|
||||||
SourceLocation L,
|
SourceLocation L,
|
||||||
ObjCInterfaceDecl *classInterface,
|
ObjCInterfaceDecl *classInterface,
|
||||||
ObjCInterfaceDecl *superDecl);
|
ObjCInterfaceDecl *superDecl);
|
||||||
|
|
||||||
|
/// Destroy - Call destructors and release memory.
|
||||||
|
virtual void Destroy(ASTContext& C);
|
||||||
|
|
||||||
void ObjCAddInstanceVariablesToClassImpl(ObjCIvarDecl **ivars,
|
void setIVarList(ObjCIvarDecl *const *InArray, unsigned Num) {
|
||||||
unsigned numIvars);
|
IVars.set(InArray, Num);
|
||||||
|
}
|
||||||
|
|
||||||
void addInstanceMethod(ObjCMethodDecl *method) {
|
void addInstanceMethod(ObjCMethodDecl *method) {
|
||||||
InstanceMethods.push_back(method);
|
InstanceMethods.push_back(method);
|
||||||
|
@ -963,11 +964,11 @@ public:
|
||||||
return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
|
return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef ObjCIvarDecl * const *ivar_iterator;
|
typedef ObjCList<ObjCIvarDecl>::iterator ivar_iterator;
|
||||||
ivar_iterator ivar_begin() const { return Ivars; }
|
ivar_iterator ivar_begin() const { return IVars.begin(); }
|
||||||
ivar_iterator ivar_end() const { return Ivars+NumIvars; }
|
ivar_iterator ivar_end() const { return IVars.end(); }
|
||||||
unsigned ivar_size() const { return NumIvars; }
|
unsigned ivar_size() const { return IVars.size(); }
|
||||||
bool ivar_empty() const { return NumIvars == 0; }
|
bool ivar_empty() const { return IVars.empty(); }
|
||||||
|
|
||||||
static bool classof(const Decl *D) {
|
static bool classof(const Decl *D) {
|
||||||
return D->getKind() == ObjCImplementation;
|
return D->getKind() == ObjCImplementation;
|
||||||
|
|
|
@ -175,6 +175,12 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
|
||||||
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
|
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Destroy - Call destructors and release memory.
|
||||||
|
void ObjCImplementationDecl::Destroy(ASTContext& C) {
|
||||||
|
IVars.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ObjCCompatibleAliasDecl *
|
ObjCCompatibleAliasDecl *
|
||||||
ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
|
ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
|
||||||
SourceLocation L,
|
SourceLocation L,
|
||||||
|
@ -250,18 +256,6 @@ FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context,
|
||||||
return MemberDecl;
|
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.
|
// Get the local instance method declared in this interface.
|
||||||
// FIXME: handle overloading, instance & class methods can have the same name.
|
// 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 = FieldDecl::Create(Context, Record,
|
||||||
FieldDecl *NewFD;
|
Loc, II, T, BitWidth,
|
||||||
|
D.getDeclSpec().getStorageClassSpec() ==
|
||||||
NewFD = FieldDecl::Create(Context, Record,
|
DeclSpec::SCS_mutable);
|
||||||
Loc, II, T, BitWidth,
|
|
||||||
D.getDeclSpec().getStorageClassSpec() ==
|
|
||||||
DeclSpec::SCS_mutable);
|
|
||||||
|
|
||||||
if (II) {
|
if (II) {
|
||||||
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
|
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
|
||||||
|
@ -3710,7 +3707,7 @@ void Sema::ActOnFields(Scope* S,
|
||||||
else if (ObjCImplementationDecl *IMPDecl =
|
else if (ObjCImplementationDecl *IMPDecl =
|
||||||
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
|
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
|
||||||
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
|
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
|
||||||
IMPDecl->ObjCAddInstanceVariablesToClassImpl(ClsFields, RecFields.size());
|
IMPDecl->setIVarList(ClsFields, RecFields.size());
|
||||||
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
|
CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче