diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2025-05-22 12:51:28 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2025-05-22 12:52:03 -0700 |
commit | 13e1a2cb2246dc5e9a4afcdacabed4d43154ec3f (patch) | |
tree | 44ef419d0d5533ac9464061a6801ed0db1c93a49 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 45f6036533bd30966f5e815568b792a7e293a0e8 (diff) | |
download | llvm-13e1a2cb2246dc5e9a4afcdacabed4d43154ec3f.zip llvm-13e1a2cb2246dc5e9a4afcdacabed4d43154ec3f.tar.gz llvm-13e1a2cb2246dc5e9a4afcdacabed4d43154ec3f.tar.bz2 |
Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)"
This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 3c23073..9c33910 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -125,21 +125,14 @@ static Expected<std::optional<uint32_t>> parseToleranceOption(StringRef Arg) { // Initialization. //===----------------------------------------------------------------------===// -namespace { template <class T> std::shared_ptr<T> make_shared_copy(const T &X) { return std::make_shared<T>(X); } -template <class T> -llvm::IntrusiveRefCntPtr<T> makeIntrusiveRefCntCopy(const T &X) { - return llvm::makeIntrusiveRefCnt<T>(X); -} -} // namespace - CompilerInvocationBase::CompilerInvocationBase() : LangOpts(std::make_shared<LangOptions>()), TargetOpts(std::make_shared<TargetOptions>()), - DiagnosticOpts(llvm::makeIntrusiveRefCnt<DiagnosticOptions>()), + DiagnosticOpts(std::make_shared<DiagnosticOptions>()), HSOpts(std::make_shared<HeaderSearchOptions>()), PPOpts(std::make_shared<PreprocessorOptions>()), AnalyzerOpts(std::make_shared<AnalyzerOptions>()), @@ -156,7 +149,7 @@ CompilerInvocationBase::deep_copy_assign(const CompilerInvocationBase &X) { if (this != &X) { LangOpts = make_shared_copy(X.getLangOpts()); TargetOpts = make_shared_copy(X.getTargetOpts()); - DiagnosticOpts = makeIntrusiveRefCntCopy(X.getDiagnosticOpts()); + DiagnosticOpts = make_shared_copy(X.getDiagnosticOpts()); HSOpts = make_shared_copy(X.getHeaderSearchOpts()); PPOpts = make_shared_copy(X.getPreprocessorOpts()); AnalyzerOpts = make_shared_copy(X.getAnalyzerOpts()); @@ -202,7 +195,6 @@ CompilerInvocation::operator=(const CowCompilerInvocation &X) { return *this; } -namespace { template <typename T> T &ensureOwned(std::shared_ptr<T> &Storage) { if (Storage.use_count() > 1) @@ -210,14 +202,6 @@ T &ensureOwned(std::shared_ptr<T> &Storage) { return *Storage; } -template <typename T> -T &ensureOwned(llvm::IntrusiveRefCntPtr<T> &Storage) { - if (Storage.useCount() > 1) - Storage = llvm::makeIntrusiveRefCnt<T>(*Storage); - return *Storage; -} -} // namespace - LangOptions &CowCompilerInvocation::getMutLangOpts() { return ensureOwned(LangOpts); } @@ -844,7 +828,8 @@ static bool RoundTrip(ParseFn Parse, GenerateFn Generate, }; // Setup a dummy DiagnosticsEngine. - DiagnosticsEngine DummyDiags(new DiagnosticIDs(), new DiagnosticOptions()); + DiagnosticOptions DummyDiagOpts; + DiagnosticsEngine DummyDiags(new DiagnosticIDs(), DummyDiagOpts); DummyDiags.setClient(new TextDiagnosticBuffer()); // Run the first parse on the original arguments with the dummy invocation and @@ -2663,9 +2648,11 @@ clang::CreateAndPopulateDiagOpts(ArrayRef<const char *> Argv) { bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args, DiagnosticsEngine *Diags, bool DefaultDiagColor) { + std::optional<DiagnosticOptions> IgnoringDiagOpts; std::optional<DiagnosticsEngine> IgnoringDiags; if (!Diags) { - IgnoringDiags.emplace(new DiagnosticIDs(), new DiagnosticOptions(), + IgnoringDiagOpts.emplace(); + IgnoringDiags.emplace(new DiagnosticIDs(), *IgnoringDiagOpts, new IgnoringDiagConsumer()); Diags = &*IgnoringDiags; } |