[all-commits] [llvm/llvm-project] 0ee06c: [clang][extract-api] Stop allocating APIRecords vi...
Daniel Grumberg via All-commits
all-commits at lists.llvm.org
Thu Mar 24 10:44:55 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0ee06c31aa57576c05c7ca3e68d2cac9ddf59811
https://github.com/llvm/llvm-project/commit/0ee06c31aa57576c05c7ca3e68d2cac9ddf59811
Author: Daniel Grumberg <dgrumberg at apple.com>
Date: 2022-03-24 (Thu, 24 Mar 2022)
Changed paths:
M clang/include/clang/ExtractAPI/API.h
M clang/lib/ExtractAPI/API.cpp
Log Message:
-----------
[clang][extract-api] Stop allocating APIRecords via BumpPtrAllocator
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.
Differential Revision: https://reviews.llvm.org/D122331
More information about the All-commits
mailing list