aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-20 21:02:11 +0000
committerChris Lattner <sabre@nondot.org>2009-02-20 21:02:11 +0000
commit88cf7a16902a9189d16653e1061cfda333187b58 (patch)
tree63ad089db40bcd23a068fee38e8d215f9f3c1461
parentab35163a5b80bf1bd49f0eebb708970f2b0e04e9 (diff)
rename ObjCList::clear() -> ObjCList::Destroy(). Require that destroy is called
before the dtor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65156 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclObjC.h5
-rw-r--r--lib/AST/DeclObjC.cpp12
2 files changed, 9 insertions, 8 deletions
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 4f51f66bb3..4d9b7f7a19 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -48,12 +48,13 @@ class ObjCList {
public:
ObjCList() : List(0), NumElts(0) {}
~ObjCList() {
- delete[] List;
+ assert(List == 0 && "Destroy should have been called before dtor");
}
- void clear() {
+ void Destroy() {
delete[] List;
NumElts = 0;
+ List = 0;
}
void set(T* const* InList, unsigned Elts) {
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 9e030d771a..ec67f5cf40 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -193,7 +193,7 @@ void ObjCMethodDecl::Destroy(ASTContext& C) {
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- ParamInfo.clear();
+ ParamInfo.Destroy();
Decl::Destroy(C);
}
@@ -280,7 +280,7 @@ void ObjCInterfaceDecl::Destroy(ASTContext &C) {
for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
- IVars.clear();
+ IVars.Destroy();
// FIXME: CategoryList?
// FIXME: Because there is no clear ownership
@@ -357,7 +357,7 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
}
void ObjCProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.clear();
+ ReferencedProtocols.Destroy();
ObjCContainerDecl::Destroy(C);
}
@@ -410,7 +410,7 @@ void ObjCClassDecl::Destroy(ASTContext &C) {
// obviating this problem. Because of this situation, referenced
// ObjCInterfaceDecls are destroyed in ~TranslationUnit.
- ForwardDecls.clear();
+ ForwardDecls.Destroy();
Decl::Destroy(C);
}
@@ -434,7 +434,7 @@ ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
}
void ObjCForwardProtocolDecl::Destroy(ASTContext &C) {
- ReferencedProtocols.clear();
+ ReferencedProtocols.Destroy();
Decl::Destroy(C);
}
@@ -524,7 +524,7 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
/// Destroy - Call destructors and release memory.
void ObjCImplementationDecl::Destroy(ASTContext& C) {
- IVars.clear();
+ IVars.Destroy();
Decl::Destroy(C);
}