[clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)
James Y Knight via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 13:13:19 PDT 2025
jyknight wrote:
I'm trying to update some non-in-tree code after this change, and I don't think I understand the newly-expected lifetime rules after this change. I see all the comments that say this makes lifetime clearer...so I expect I'm just misunderstanding things.
Previously, DiagnosticsEngine kept a DiagnosticOptions member via IntrusiveRefCntPtr, which meant the DiagnosticsOptions lifetime would be at least as long as the DiagnosticsEngine.
Now, it stores a reference. Which means, I think, that the creator of a DiagnosticsEngine needs to somehow ensure by themselves that the DiagnosticsOptions value has a sufficiently long lifetime.
But this seems very hard to figure out what lifetimes should be now, because DiagnosticsEngine is, itself, refcounted. How does it make sense to have a borrowed reference to DiagnosticsOption in the refcounted DiagnosticsEngine type? ISTM the caller who creates a DiagnosticsEngine cannot now easily know what the lifetime of the DiagnosticsEngine is going to be, and thus, has no way to ensure the DiagnosticsOptions lifetime is correct?
https://github.com/llvm/llvm-project/pull/139584
More information about the cfe-commits
mailing list