Skip to content

Commit 0025170

Browse files
jansvoboda11GeorgeARM
authored andcommitted
[clang] Make the AnalyzerOptions reference count non-intrusive (llvm#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: llvm#133467 (comment)
1 parent 412fee2 commit 0025170

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class CompilerInvocationBase {
8989
std::shared_ptr<PreprocessorOptions> PPOpts;
9090

9191
/// Options controlling the static analyzer.
92-
AnalyzerOptionsRef AnalyzerOpts;
92+
std::shared_ptr<AnalyzerOptions> AnalyzerOpts;
9393

9494
std::shared_ptr<MigratorOptions> MigratorOpts;
9595

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class PositiveAnalyzerOption {
176176
/// and should be eventually converted into -analyzer-config flags. New analyzer
177177
/// options should not be implemented as frontend flags. Frontend flags still
178178
/// make sense for things that do not affect the actual analysis.
179-
class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
179+
class AnalyzerOptions {
180180
public:
181181
using ConfigTable = llvm::StringMap<std::string>;
182182

@@ -416,8 +416,6 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
416416
}
417417
};
418418

419-
using AnalyzerOptionsRef = IntrusiveRefCntPtr<AnalyzerOptions>;
420-
421419
//===----------------------------------------------------------------------===//
422420
// We'll use AnalyzerOptions in the frontend, but we can't link the frontend
423421
// with clangStaticAnalyzerCore, because clangStaticAnalyzerCore depends on

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ CompilerInvocationBase::CompilerInvocationBase()
142142
DiagnosticOpts(llvm::makeIntrusiveRefCnt<DiagnosticOptions>()),
143143
HSOpts(std::make_shared<HeaderSearchOptions>()),
144144
PPOpts(std::make_shared<PreprocessorOptions>()),
145-
AnalyzerOpts(llvm::makeIntrusiveRefCnt<AnalyzerOptions>()),
145+
AnalyzerOpts(std::make_shared<AnalyzerOptions>()),
146146
MigratorOpts(std::make_shared<MigratorOptions>()),
147147
APINotesOpts(std::make_shared<APINotesOptions>()),
148148
CodeGenOpts(std::make_shared<CodeGenOptions>()),
@@ -159,7 +159,7 @@ CompilerInvocationBase::deep_copy_assign(const CompilerInvocationBase &X) {
159159
DiagnosticOpts = makeIntrusiveRefCntCopy(X.getDiagnosticOpts());
160160
HSOpts = make_shared_copy(X.getHeaderSearchOpts());
161161
PPOpts = make_shared_copy(X.getPreprocessorOpts());
162-
AnalyzerOpts = makeIntrusiveRefCntCopy(X.getAnalyzerOpts());
162+
AnalyzerOpts = make_shared_copy(X.getAnalyzerOpts());
163163
MigratorOpts = make_shared_copy(X.getMigratorOpts());
164164
APINotesOpts = make_shared_copy(X.getAPINotesOpts());
165165
CodeGenOpts = make_shared_copy(X.getCodeGenOpts());

0 commit comments

Comments
 (0)