[lld] r281425 - Simplify InputFile ownership management.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 17:22:26 PDT 2016


On Mon, Sep 19, 2016 at 3:36 PM, Rui Ueyama via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> It has an advantage in terms of consistency with the lifetime management for
> other objects such as OutputSection. For those that we instantiate during
> linking and don't release until everything is done, we simply put them into
> a global structure and don't do fine-grained lifetime management. One
> concern would be to make thread-safe, but the global variable can be a
> thread-local one, so it can be resolved. And I think this is also easier to
> read -- but you have a different opinion on this, I guess?
>

I'm not quite sure I find the new version more readable. The main
concern I have with this patch is that it takes a relatively sane
resource lifetime management and puts it aside, to replace it with raw
pointers. `std::unique_ptr<>` makes very clear that the object gets
destroyed when the ptr goes out of scope. I think the new version
doesn't, and that's why I find it not ideal. That said, I'm not asking
for a revert, I think it would be excessive.

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list