[PATCH] D122331: [clang][extract-api] Stop allocating APIRecords via BumpPtrAllocator

Daniel Grumberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 10:20:09 PDT 2022


dang created this revision.
dang added reviewers: zixuw, QuietMisdreavus, ributzka.
Herald added a project: All.
dang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Using a BumpPtrAllocator introduced memory leaks for APIRecords as they
contain a std::vector. This meant that we needed to always keep a
reference to the records in APISet and arrange for their destructor to
get called appropriately. This was further complicated by the need for
records to own sub-records as these subrecords would still need to be
allocated via the BumpPtrAllocator and the owning record would now need
to arrange for the destructor of its subrecords to be called
appropriately.

Since APIRecords contain a std::vector so whenever elements get added to
that there is an associated heap allocation regardless. Since
performance isn't currently our main priority it makes sense to use
regular unique_ptr to keep track of APIRecords, this way we don't need
to arrange for destructors to get called.

The BumpPtrAllocator is still used for strings such as USRs so that we
can easily de-duplicate them as necessary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122331

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/lib/ExtractAPI/API.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122331.417682.patch
Type: text/x-patch
Size: 6087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220323/9bb3c1ce/attachment.bin>


More information about the cfe-commits mailing list