================ @@ -107,6 +107,7 @@ class ASTUnit { private: std::unique_ptr<LangOptions> LangOpts; + std::shared_ptr<DiagnosticOptions> DiagOpts; ---------------- jansvoboda11 wrote:
I was hoping it could be, but the situation is a bit weird. The documentation for `ASTUnit::LoadFromCommandLine()` says the `DiagnosticsEngine` parameter is expected to outlive the returned value. However, it's being passed in `IntrusiveRefCntPtr`, so the lifetime is not enforced, and of course some clients started to rely on `ASTUnit` taking shared ownership of that object. And the clients also use the `DiagnosticsEngine` object themselves after passing it to that function, so the ownership is indeed shared. And since `DiagnosticsEngine` now relies on `DiagnosticOptions` to live long enough, sharing ownership in `ASTUnit` was the best fit. Does that make sense? In general `ASTUnit` is a big pile of lifetime hacks which I'd like to clean up one day, but today is not the day. https://github.com/llvm/llvm-project/pull/139584 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits