[llvm] [LLVM][DWARF] Fix for memory leak (PR #81828)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 15 09:45:24 PST 2024
================
@@ -251,7 +251,10 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
const DWARF5AccelTableData &)>
getIndexForEntry,
bool IsSplitDwarf);
-
+ ~Dwarf5AccelTableWriter() {
+ for (DebugNamesAbbrev *Abbrev : AbbreviationsVector)
+ Abbrev->~DebugNamesAbbrev();
+ }
----------------
ayermolo wrote:
We can.... I don't really have a strong opinion on this.
It will look something like
```
std::unique_ptr<DebugNamesAbbrev> NewAbbrev =
std::make_unique<DebugNamesAbbrev>(std::move(Abbrev));
NewAbbrev->setNumber(AbbreviationsVector.size() + 1);
AbbreviationsVector.push_back(std::move(NewAbbrev));
AbbreviationsSet.InsertNode(AbbreviationsVector.back().get(), InsertPos);
Value->setAbbrevNumber(AbbreviationsVector.back()->getNumber());
```
Couple reasons for leaving it like this
1) Bumpptr allocator seems to be a more standard way of dong things, although it can lead to situations like this.
2) This is also how .debug_abbrev handles it. Since we are going for convergence at some point.
https://github.com/llvm/llvm-project/pull/81828
More information about the llvm-commits
mailing list