[Lldb-commits] [clang] [clang-tools-extra] [lldb] [clang] Remove intrusive reference count from `DiagnosticOptions` (PR #139584)

Jan Svoboda via lldb-commits lldb-commits at lists.llvm.org
Wed May 14 07:43:00 PDT 2025


================
@@ -2032,6 +2032,7 @@ class SourceManagerForFile {
   // as they are created in `createSourceManagerForFile` so that they can be
   // deleted in the reverse order as they are created.
   std::unique_ptr<FileManager> FileMgr;
+  std::unique_ptr<DiagnosticOptions> DiagOpts;
----------------
jansvoboda11 wrote:

I don't think I understand. Now that `DiagnosticOptions` are not intrusively reference-counted, raw pointers have clearer semantics than before (typically nullable non-owning borrow), no? I'd also argue that using values, references, raw pointers, `unique_ptr` and `shared_ptr` depending on the context is the clearest way to communicate lifetimes and ownership. Regardless, there's only one raw pointer to `DiagnosticOptions` remaining after my patch in `clang::tooling::ToolInvocation`, and that has exactly the semantics you'd expect: optional borrow where the owner is someone else and you expect them to keep the object alive long enough.

https://github.com/llvm/llvm-project/pull/139584


More information about the lldb-commits mailing list