From cebaf0cea1f2cf9d71b4d965104e08a7ff6c89c4 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 28 Apr 2025 12:42:03 -0700 Subject: [clang] Make the `AnalyzerOptions` reference count non-intrusive (#137680) This PR makes `CompilerInvocation` the sole owner of the `AnalyzerOptions` instance. Clients can no longer become co-owners by doing something like this: ```c++ void shareOwnership(CompilerInvocation &CI) { IntrusiveRefCntPtr Shared = &CI.getAnalyzerOpts(); } ``` The motivation for this is given here: https://github.com/llvm/llvm-project/pull/133467#issuecomment-2762065443 --- clang/lib/Frontend/CompilerInvocation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1df5038..8ff62ae2 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -142,7 +142,7 @@ CompilerInvocationBase::CompilerInvocationBase() DiagnosticOpts(llvm::makeIntrusiveRefCnt()), HSOpts(std::make_shared()), PPOpts(std::make_shared()), - AnalyzerOpts(llvm::makeIntrusiveRefCnt()), + AnalyzerOpts(std::make_shared()), MigratorOpts(std::make_shared()), APINotesOpts(std::make_shared()), CodeGenOpts(std::make_shared()), @@ -159,7 +159,7 @@ CompilerInvocationBase::deep_copy_assign(const CompilerInvocationBase &X) { DiagnosticOpts = makeIntrusiveRefCntCopy(X.getDiagnosticOpts()); HSOpts = make_shared_copy(X.getHeaderSearchOpts()); PPOpts = make_shared_copy(X.getPreprocessorOpts()); - AnalyzerOpts = makeIntrusiveRefCntCopy(X.getAnalyzerOpts()); + AnalyzerOpts = make_shared_copy(X.getAnalyzerOpts()); MigratorOpts = make_shared_copy(X.getMigratorOpts()); APINotesOpts = make_shared_copy(X.getAPINotesOpts()); CodeGenOpts = make_shared_copy(X.getCodeGenOpts()); -- cgit v1.1