]> granicus.if.org Git - clang/commitdiff
Fix crasher due to use-after-release: DeclContext now owns all ObjCMethodDecls, and...
authorTed Kremenek <kremenek@apple.com>
Mon, 12 Jan 2009 22:49:54 +0000 (22:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 12 Jan 2009 22:49:54 +0000 (22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62113 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 9139050660771b756043aa10162b015feef04a70..f11608f04aab64c8b5a29b1d66a08fd2811580c9 100644 (file)
@@ -602,10 +602,6 @@ class ObjCProtocolDecl : public ObjCContainerDecl {
   virtual ~ObjCProtocolDecl();
   
 public:
-    
-  /// Destroy - Call destructors and release memory.
-  virtual void Destroy(ASTContext& C);
-  
   static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, 
                                   SourceLocation L, IdentifierInfo *Id);
 
index 9fc0f763bbd90586e58fccac0ad688a0feea04d9..ea7a047780c8e88b75bfa26a76fad2957d66b00b 100644 (file)
@@ -73,13 +73,9 @@ void ObjCInterfaceDecl::Destroy(ASTContext& C) {
   for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I)
     if (*I) (*I)->Destroy(C);
   
-  for (method_iterator I=meth_begin(), E=meth_end(); I!=E; ++I)
-    if (*I) const_cast<ObjCMethodDecl*>((*I))->Destroy(C);
-
   // FIXME: Because there is no clear ownership
   //  role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
   //  reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
-
   Decl::Destroy(C);
 }
 
@@ -115,20 +111,6 @@ ObjCProtocolDecl::~ObjCProtocolDecl() {
   delete [] PropertyDecl;
 }
 
-void ObjCProtocolDecl::Destroy(ASTContext& C) {
-  
-  // Referenced Protocols are not owned, so don't Destroy them.
-  
-  for (method_iterator I=meth_begin(), E=meth_end(); I!=E; ++I)
-    if (*I) const_cast<ObjCMethodDecl*>((*I))->Destroy(C);
-  
-  // FIXME: Because there is no clear ownership
-  //  role between ObjCProtocolDecls and the ObjCPropertyDecls that they
-  //  reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
-  
-  Decl::Destroy(C);
-}
-
 
 ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
                                      SourceLocation L,