[cfe-commits] r65111 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp
Chris Lattner
sabre at nondot.org
Thu Feb 19 21:54:35 PST 2009
Author: lattner
Date: Thu Feb 19 23:54:35 2009
New Revision: 65111
URL: http://llvm.org/viewvc/llvm-project?rev=65111&view=rev
Log:
move some objc decl destruction out of dtors into Destroy method.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=65111&r1=65110&r2=65111&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Feb 19 23:54:35 2009
@@ -151,7 +151,9 @@
ParamInfo(0), NumMethodParams(0),
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
- virtual ~ObjCMethodDecl();
+ virtual ~ObjCMethodDecl() {
+ assert(ParamInfo == 0 && "Destroy not called?");
+ }
public:
@@ -595,12 +597,17 @@
isForwardProtoDecl(true) {
}
- virtual ~ObjCProtocolDecl();
+ virtual ~ObjCProtocolDecl() {
+ assert(PropertyDecl == 0 && "Destroy not called?");
+ }
public:
static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
+ /// Destroy - Call destructors and release memory.
+ virtual void Destroy(ASTContext& C);
+
const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
return ReferencedProtocols;
}
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=65111&r1=65110&r2=65111&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Feb 19 23:54:35 2009
@@ -35,17 +35,16 @@
isVariadic, isSynthesized, impControl);
}
-ObjCMethodDecl::~ObjCMethodDecl() {
- delete [] ParamInfo;
-}
-
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);
-
+
+ delete [] ParamInfo;
+ ParamInfo = 0;
+
Decl::Destroy(C);
}
@@ -102,11 +101,15 @@
return new (C) ObjCProtocolDecl(DC, L, Id);
}
-ObjCProtocolDecl::~ObjCProtocolDecl() {
+void ObjCProtocolDecl::Destroy(ASTContext &C) {
delete [] PropertyDecl;
+ PropertyDecl = 0;
+ ObjCContainerDecl::Destroy(C);
}
+
+
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
ObjCInterfaceDecl **Elts, unsigned nElts) {
More information about the cfe-commits
mailing list