SelName(SelInfo), MethodDeclType(T),
ParamInfo(0), NumMethodParams(0),
MethodAttrs(M), EndLoc(endLoc), Body(0), SelfDecl(0) {}
+
~ObjCMethodDecl();
public:
+
+ /// Destroy - Call destructors and release memory.
+ virtual void Destroy(ASTContext& C);
static ObjCMethodDecl *Create(ASTContext &C,
SourceLocation beginLoc,
ClassLoc(CLoc) {
AllocIntfRefProtocols(numRefProtos);
}
+
+ ~ObjCInterfaceDecl();
+
public:
+ /// Destroy - Call destructors and release memory.
+ virtual void Destroy(ASTContext& C);
+
static ObjCInterfaceDecl *Create(ASTContext &C,
SourceLocation atLoc,
unsigned numRefProtos,
isVariadic, isSynthesized, impControl);
}
+ObjCMethodDecl::~ObjCMethodDecl() {
+ delete [] ParamInfo;
+ //delete [] MethodAttrs; // FIXME: Also destroy the stored Expr*.
+}
+
+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);
+
+ Decl::Destroy(C);
+}
+
ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
SourceLocation atLoc,
unsigned numRefProtos,
isInternal);
}
+ObjCInterfaceDecl::~ObjCInterfaceDecl() {
+ delete [] Ivars;
+ delete [] InstanceMethods;
+ delete [] ClassMethods;
+ delete [] PropertyDecl;
+ // FIXME: CategoryList?
+}
+
+void ObjCInterfaceDecl::Destroy(ASTContext& C) {
+ for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
+ if (*I) (*I)->Destroy(C);
+
+ for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I)
+ if (*I) (*I)->Destroy(C);
+
+ for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I)
+ if (*I) (*I)->Destroy(C);
+
+ // FIXME: Cannot destroy properties right now because the properties of
+ // both the super class and this class are in this array. This can
+ // cause double-deletions.
+ //for (classprop_iterator I=classprop_begin(), E=classprop_end(); I!=E; ++I)
+// if (*I) (*I)->Destroy(C);
+//
+ Decl::Destroy(C);
+}
+
+
ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id, QualType T) {
void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
}
}
-ObjCMethodDecl::~ObjCMethodDecl() {
- delete[] ParamInfo;
-}
-
/// FindPropertyDeclaration - Finds declaration of the property given its name
/// in 'PropertyId' and returns it. It returns 0, if not found.
///
///
void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
tok::ObjCKeywordKind contextKey) {
- llvm::SmallVector<DeclTy*, 32> allMethods;
+ llvm::SmallVector<DeclTy*, 32> allMethods;
llvm::SmallVector<DeclTy*, 16> allProperties;
tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
SourceLocation AtEndLoc;
}
}
/// Insert collected methods declarations into the @interface object.
- Actions.ActOnAtEnd(AtEndLoc, interfaceDecl, &allMethods[0], allMethods.size(),
- &allProperties[0], allProperties.size());
+ Actions.ActOnAtEnd(AtEndLoc, interfaceDecl,
+ allMethods.empty() ? 0 : &allMethods[0],
+ allMethods.size(),
+ allProperties.empty() ? 0 : &allProperties[0],
+ allProperties.size());
}
/// Parse property attribute declarations.