mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Use a vector of unique_ptrs to fix a memory leak introduced in r208179.
Also removed an inaccurate comment that stated that a DenseMap was used as storage for the ListInit*'s. It's currently using a FoldingSet. I expect there's a better way to fix this but I haven't found it yet. FoldingSet is incompatible with the Pool template and I'm not sure if FoldingSet can be safely replaced with a DenseMap of computed FoldingSetID's to ListInit*'s. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208293 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f35ce2376c
commit
01ce4b98ce
@ -623,9 +623,8 @@ static void ProfileListInit(FoldingSetNodeID &ID,
|
|||||||
ListInit *ListInit::get(ArrayRef<Init *> Range, RecTy *EltTy) {
|
ListInit *ListInit::get(ArrayRef<Init *> Range, RecTy *EltTy) {
|
||||||
typedef FoldingSet<ListInit> Pool;
|
typedef FoldingSet<ListInit> Pool;
|
||||||
static Pool ThePool;
|
static Pool ThePool;
|
||||||
|
static std::vector<std::unique_ptr<ListInit>> TheActualPool;
|
||||||
|
|
||||||
// Just use the FoldingSetNodeID to compute a hash. Use a DenseMap
|
|
||||||
// for actual storage.
|
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
ProfileListInit(ID, Range, EltTy);
|
ProfileListInit(ID, Range, EltTy);
|
||||||
|
|
||||||
@ -635,6 +634,7 @@ ListInit *ListInit::get(ArrayRef<Init *> Range, RecTy *EltTy) {
|
|||||||
|
|
||||||
ListInit *I = new ListInit(Range, EltTy);
|
ListInit *I = new ListInit(Range, EltTy);
|
||||||
ThePool.InsertNode(I, IP);
|
ThePool.InsertNode(I, IP);
|
||||||
|
TheActualPool.push_back(std::unique_ptr<ListInit>(I));
|
||||||
return I;
|
return I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user