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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to