From: Ted Kremenek Date: Thu, 11 Feb 2010 00:53:01 +0000 (+0000) Subject: Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator.... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=298ed870c7d8edf243edf14d624e577d4a3a8800;p=clang Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator. Previously they were not getting freed. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95834 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 655d59fa8b..2a22132ea8 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -436,7 +436,9 @@ public: continue; } - Prev->Next = new ObjCMethodList(Method, 0); + ObjCMethodList *Mem = + Reader.getSema()->BumpAlloc.Allocate(); + Prev->Next = new (Mem) ObjCMethodList(Method, 0); Prev = Prev->Next; } @@ -452,7 +454,9 @@ public: continue; } - Prev->Next = new ObjCMethodList(Method, 0); + ObjCMethodList *Mem = + Reader.getSema()->BumpAlloc.Allocate(); + Prev->Next = new (Mem) ObjCMethodList(Method, 0); Prev = Prev->Next; } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 13eeb6c761..af51fb10c1 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1490,7 +1490,8 @@ void Sema::AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method) { // 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(); + Entry.Next = new (Mem) ObjCMethodList(Method, Entry.Next); } // FIXME: Finish implementing -Wno-strict-selector-match. @@ -1553,7 +1554,8 @@ void Sema::AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method) { 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 *OMI = new (Mem) ObjCMethodList(Method, FirstMethod.Next); FirstMethod.Next = OMI; } }