[cfe-commits] r95834 - in /cfe/trunk/lib: Frontend/PCHReader.cpp Sema/SemaDeclObjC.cpp

Ted Kremenek kremenek at apple.com
Wed Feb 10 16:53:01 PST 2010


Author: kremenek
Date: Wed Feb 10 18:53:01 2010
New Revision: 95834

URL: http://llvm.org/viewvc/llvm-project?rev=95834&view=rev
Log:
Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator.  Previously they were not getting freed.  Fixes <rdar://problem/7635663>.

Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=95834&r1=95833&r2=95834&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Wed Feb 10 18:53:01 2010
@@ -436,7 +436,9 @@
         continue;
       }
 
-      Prev->Next = new ObjCMethodList(Method, 0);
+      ObjCMethodList *Mem =
+        Reader.getSema()->BumpAlloc.Allocate<ObjCMethodList>();
+      Prev->Next = new (Mem) ObjCMethodList(Method, 0);
       Prev = Prev->Next;
     }
 
@@ -452,7 +454,9 @@
         continue;
       }
 
-      Prev->Next = new ObjCMethodList(Method, 0);
+      ObjCMethodList *Mem =
+        Reader.getSema()->BumpAlloc.Allocate<ObjCMethodList>();
+      Prev->Next = new (Mem) ObjCMethodList(Method, 0);
       Prev = Prev->Next;
     }
 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=95834&r1=95833&r2=95834&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Feb 10 18:53:01 2010
@@ -1490,7 +1490,8 @@
 
   // We have a new signature for an existing method - add it.
   // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
-  Entry.Next = new ObjCMethodList(Method, Entry.Next);
+  ObjCMethodList *Mem = BumpAlloc.Allocate<ObjCMethodList>();
+  Entry.Next = new (Mem) ObjCMethodList(Method, Entry.Next);
 }
 
 // FIXME: Finish implementing -Wno-strict-selector-match.
@@ -1553,7 +1554,8 @@
     if (!match) {
       // We have a new signature for an existing method - add it.
       // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
-      struct ObjCMethodList *OMI = new ObjCMethodList(Method, FirstMethod.Next);
+      ObjCMethodList *Mem = BumpAlloc.Allocate<ObjCMethodList>();
+      ObjCMethodList *OMI = new (Mem) ObjCMethodList(Method, FirstMethod.Next);
       FirstMethod.Next = OMI;
     }
   }





More information about the cfe-commits mailing list