forked from OSchip/llvm-project
Add optional allocator to YAML code to avoid leaking lld atoms.
In lld we allocate atoms on an allocator and so don't run their destructors. This means we also shouldn't allocate memory inside them without that also being on an allocator. Reviewed by Lang Hames and Rafael Espindola. llvm-svn: 263676
This commit is contained in:
parent
b672e792f2
commit
5b78308689
|
@ -894,12 +894,16 @@ private:
|
|||
// to [de]normalize an object for use with YAML conversion.
|
||||
template <typename TNorm, typename TFinal>
|
||||
struct MappingNormalizationHeap {
|
||||
MappingNormalizationHeap(IO &i_o, TFinal &Obj)
|
||||
MappingNormalizationHeap(IO &i_o, TFinal &Obj,
|
||||
llvm::BumpPtrAllocator *allocator = nullptr)
|
||||
: io(i_o), BufPtr(nullptr), Result(Obj) {
|
||||
if ( io.outputting() ) {
|
||||
BufPtr = new (&Buffer) TNorm(io, Obj);
|
||||
}
|
||||
else {
|
||||
else if (allocator) {
|
||||
BufPtr = allocator->Allocate<TNorm>();
|
||||
new (BufPtr) TNorm(io);
|
||||
} else {
|
||||
BufPtr = new TNorm(io);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue