[cfe-commits] r62113 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp

Ted Kremenek kremenek at apple.com
Mon Jan 12 14:49:54 PST 2009


Author: kremenek
Date: Mon Jan 12 16:49:54 2009
New Revision: 62113

URL: http://llvm.org/viewvc/llvm-project?rev=62113&view=rev
Log:
Fix crasher due to use-after-release: DeclContext now owns all ObjCMethodDecls, and shouldn't be released elsewhere.

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=62113&r1=62112&r2=62113&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Mon Jan 12 16:49:54 2009
@@ -602,10 +602,6 @@
   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);
 

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=62113&r1=62112&r2=62113&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Jan 12 16:49:54 2009
@@ -73,13 +73,9 @@
   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 @@
   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,





More information about the cfe-commits mailing list