]> granicus.if.org Git - clang/commitdiff
Because of a lack of a clear ownership role between ObjCInterfaceDecls and
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Jun 2008 17:21:42 +0000 (17:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Jun 2008 17:21:42 +0000 (17:21 +0000)
ObjCPropertyDecls, have TranslationUnit destroy ObjCPropertyDecls. This is a
horrible hack, and must be removed eventually.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52051 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclObjC.cpp
lib/AST/TranslationUnit.cpp

index f3d81a1aa509f08eca4748c34bd08b23c6c173bd..b3fc131330eebb19302228c327425e4c446cede7 100644 (file)
@@ -79,13 +79,11 @@ void ObjCInterfaceDecl::Destroy(ASTContext& 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);
-//  
+
+  // FIXME: Because there is no clear ownership
+  //  role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
+  //  reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
+
   Decl::Destroy(C);
 }
 
index f8416f18fa1d7aa888659c6e68f2364a03f760da..e78502f267d67bca6bc49401a081483c1c74fe7b 100644 (file)
@@ -37,6 +37,20 @@ TranslationUnit::~TranslationUnit() {
       if (Killed.count(*I)) continue;
 
       Killed.insert(*I);
+      
+      // FIXME: This is a horrible hack.  Because there is no clear ownership
+      //  role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
+      //  reference, we need to destroy ObjCPropertyDecls here.  This will
+      //  eventually be fixed when the ownership of ObjCPropertyDecls gets
+      //  cleaned up.
+      if (ObjCInterfaceDecl* IDecl = dyn_cast<ObjCInterfaceDecl>(*I))
+        for (ObjCInterfaceDecl::classprop_iterator ID=IDecl->classprop_begin(),
+             ED=IDecl->classprop_end(); ID!=ED; ++ID) {
+          if (Killed.count(*ID)) continue;
+          Killed.insert(*ID);
+          (*ID)->Destroy(*Context);
+        }
+      
       (*I)->Destroy(*Context);
     }
   }