aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Diagnostic.cpp10
-rw-r--r--clang/lib/Basic/SourceManager.cpp4
-rw-r--r--clang/lib/CrossTU/CrossTranslationUnit.cpp20
-rw-r--r--clang/lib/Frontend/ASTMerge.cpp13
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp14
-rw-r--r--clang/lib/Frontend/ChainedIncludesSource.cpp4
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp27
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp27
-rw-r--r--clang/lib/Frontend/CreateInvocationFromCommandLine.cpp14
-rw-r--r--clang/lib/Frontend/DiagnosticRenderer.cpp17
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp12
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp16
-rw-r--r--clang/lib/Frontend/LogDiagnosticPrinter.cpp4
-rw-r--r--clang/lib/Frontend/SARIFDiagnostic.cpp4
-rw-r--r--clang/lib/Frontend/SARIFDiagnosticPrinter.cpp7
-rw-r--r--clang/lib/Frontend/SerializedDiagnosticPrinter.cpp29
-rw-r--r--clang/lib/Frontend/TextDiagnostic.cpp79
-rw-r--r--clang/lib/Frontend/TextDiagnosticPrinter.cpp15
-rw-r--r--clang/lib/Interpreter/CodeCompletion.cpp3
-rw-r--r--clang/lib/Interpreter/Interpreter.cpp8
-rw-r--r--clang/lib/Rewrite/HTMLRewrite.cpp4
-rw-r--r--clang/lib/Serialization/ASTReader.cpp25
-rw-r--r--clang/lib/Testing/TestAST.cpp2
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp8
-rw-r--r--clang/lib/Tooling/Core/Replacement.cpp4
-rw-r--r--clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp6
-rw-r--r--clang/lib/Tooling/Refactoring.cpp8
-rw-r--r--clang/lib/Tooling/Tooling.cpp10
28 files changed, 193 insertions, 201 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index b48eed8..2282141 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -77,11 +77,11 @@ DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT,
Output.append(Str.begin(), Str.end());
}
-DiagnosticsEngine::DiagnosticsEngine(
- IntrusiveRefCntPtr<DiagnosticIDs> diags,
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, DiagnosticConsumer *client,
- bool ShouldOwnClient)
- : Diags(std::move(diags)), DiagOpts(std::move(DiagOpts)) {
+DiagnosticsEngine::DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> diags,
+ DiagnosticOptions &DiagOpts,
+ DiagnosticConsumer *client,
+ bool ShouldOwnClient)
+ : Diags(std::move(diags)), DiagOpts(DiagOpts) {
setClient(client, ShouldOwnClient);
ArgToStringFn = DummyArgToStringFn;
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 4028bbf..09e5c65 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2391,11 +2391,11 @@ SourceManagerForFile::SourceManagerForFile(StringRef FileName,
// in `Environment` so that `FileMgr` can out-live this function scope.
FileMgr =
std::make_unique<FileManager>(FileSystemOptions(), InMemoryFileSystem);
+ DiagOpts = std::make_unique<DiagnosticOptions>();
// This is passed to `SM` as reference, so the pointer has to be referenced
// by `Environment` due to the same reason above.
Diagnostics = std::make_unique<DiagnosticsEngine>(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
- new DiagnosticOptions);
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), *DiagOpts);
SourceMgr = std::make_unique<SourceManager>(*Diagnostics, *FileMgr);
FileEntryRef FE = llvm::cantFail(FileMgr->getFileRef(FileName));
FileID ID =
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index ef395f4..6d0f042 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -560,15 +560,15 @@ CrossTranslationUnitContext::ASTLoader::load(StringRef Identifier) {
CrossTranslationUnitContext::LoadResultTy
CrossTranslationUnitContext::ASTLoader::loadFromDump(StringRef ASTDumpPath) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
+ auto DiagOpts = std::make_shared<DiagnosticOptions>();
TextDiagnosticPrinter *DiagClient =
- new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+ new TextDiagnosticPrinter(llvm::errs(), *DiagOpts);
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+ new DiagnosticsEngine(DiagID, *DiagOpts, DiagClient));
return ASTUnit::LoadFromASTFile(
ASTDumpPath, CI.getPCHContainerOperations()->getRawReader(),
- ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
+ ASTUnit::LoadEverything, DiagOpts, Diags, CI.getFileSystemOpts(),
CI.getHeaderSearchOpts());
}
@@ -603,17 +603,17 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource(
CommandLineArgs.begin(),
[](auto &&CmdPart) { return CmdPart.c_str(); });
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts{&CI.getDiagnosticOpts()};
+ auto DiagOpts = std::make_shared<DiagnosticOptions>(CI.getDiagnosticOpts());
auto *DiagClient = new ForwardingDiagnosticConsumer{CI.getDiagnosticClient()};
IntrusiveRefCntPtr<DiagnosticIDs> DiagID{
CI.getDiagnostics().getDiagnosticIDs()};
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine{DiagID, &*DiagOpts, DiagClient});
+ new DiagnosticsEngine{DiagID, *DiagOpts, DiagClient});
- return ASTUnit::LoadFromCommandLine(CommandLineArgs.begin(),
- (CommandLineArgs.end()),
- CI.getPCHContainerOperations(), Diags,
- CI.getHeaderSearchOpts().ResourceDir);
+ return ASTUnit::LoadFromCommandLine(
+ CommandLineArgs.begin(), (CommandLineArgs.end()),
+ CI.getPCHContainerOperations(), DiagOpts, Diags,
+ CI.getHeaderSearchOpts().ResourceDir);
}
llvm::Expected<InvocationListTy>
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp
index b6b0644..a4ce883 100644
--- a/clang/lib/Frontend/ASTMerge.cpp
+++ b/clang/lib/Frontend/ASTMerge.cpp
@@ -41,14 +41,13 @@ void ASTMergeAction::ExecuteAction() {
auto SharedState = std::make_shared<ASTImporterSharedState>(
*CI.getASTContext().getTranslationUnitDecl());
for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) {
- IntrusiveRefCntPtr<DiagnosticsEngine>
- Diags(new DiagnosticsEngine(DiagIDs, &CI.getDiagnosticOpts(),
- new ForwardingDiagnosticConsumer(
- *CI.getDiagnostics().getClient()),
- /*ShouldOwnClient=*/true));
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags(new DiagnosticsEngine(
+ DiagIDs, CI.getDiagnosticOpts(),
+ new ForwardingDiagnosticConsumer(*CI.getDiagnostics().getClient()),
+ /*ShouldOwnClient=*/true));
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
- ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
- CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
+ ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything,
+ nullptr, Diags, CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
if (!Unit)
continue;
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 5a79fe0..457043c 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -803,7 +803,8 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
- WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ WhatToLoad ToLoad, std::shared_ptr<DiagnosticOptions> DiagOpts,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, const HeaderSearchOptions &HSOpts,
const LangOptions *LangOpts, bool OnlyLocalDecls,
CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
@@ -823,6 +824,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
: std::make_unique<LangOptions>();
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
+ AST->DiagOpts = DiagOpts;
AST->Diagnostics = Diags;
AST->FileMgr = new FileManager(FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
@@ -1534,6 +1536,7 @@ StringRef ASTUnit::getASTFileName() const {
std::unique_ptr<ASTUnit>
ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
CaptureDiagsKind CaptureDiagnostics,
bool UserFilesAreVolatile) {
@@ -1541,6 +1544,7 @@ ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
createVFSFromCompilerInvocation(*CI, *Diags);
+ AST->DiagOpts = DiagOpts;
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
AST->Invocation = std::move(CI);
@@ -1556,6 +1560,7 @@ ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FrontendAction *Action,
ASTUnit *Unit, bool Persistent, StringRef ResourceFilesPath,
bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
@@ -1567,7 +1572,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
ASTUnit *AST = Unit;
if (!AST) {
// Create the AST unit.
- OwnAST = create(CI, Diags, CaptureDiagnostics, UserFilesAreVolatile);
+ OwnAST =
+ create(CI, DiagOpts, Diags, CaptureDiagnostics, UserFilesAreVolatile);
AST = OwnAST.get();
if (!AST)
return nullptr;
@@ -1729,6 +1735,7 @@ bool ASTUnit::LoadFromCompilerInvocation(
std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
@@ -1737,6 +1744,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
// Create the AST unit.
std::unique_ptr<ASTUnit> AST(new ASTUnit(false));
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+ AST->DiagOpts = DiagOpts;
AST->Diagnostics = Diags;
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
@@ -1766,6 +1774,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
bool StorePreamblesInMemory, StringRef PreambleStoragePath,
bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
@@ -1828,6 +1837,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
AST->NumStoredDiagnosticsFromDriver = StoredDiagnostics.size();
AST->StoredDiagnostics.swap(StoredDiagnostics);
ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+ AST->DiagOpts = DiagOpts;
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp
index 95b0ed2..f9a398d 100644
--- a/clang/lib/Frontend/ChainedIncludesSource.cpp
+++ b/clang/lib/Frontend/ChainedIncludesSource.cpp
@@ -117,10 +117,10 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
CInvok->getFrontendOpts().Inputs.push_back(InputFile);
TextDiagnosticPrinter *DiagClient =
- new TextDiagnosticPrinter(llvm::errs(), new DiagnosticOptions());
+ new TextDiagnosticPrinter(llvm::errs(), CI.getDiagnosticOpts());
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient));
+ new DiagnosticsEngine(DiagID, CI.getDiagnosticOpts(), DiagClient));
auto Clang = std::make_unique<CompilerInstance>(
std::move(CInvok), CI.getPCHContainerOperations());
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 503d364..cc39049 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -280,20 +280,20 @@ static void collectVFSEntries(CompilerInstance &CI,
}
// Diagnostics
-static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
+static void SetUpDiagnosticLog(DiagnosticOptions &DiagOpts,
const CodeGenOptions *CodeGenOpts,
DiagnosticsEngine &Diags) {
std::error_code EC;
std::unique_ptr<raw_ostream> StreamOwner;
raw_ostream *OS = &llvm::errs();
- if (DiagOpts->DiagnosticLogFile != "-") {
+ if (DiagOpts.DiagnosticLogFile != "-") {
// Create the output stream.
auto FileOS = std::make_unique<llvm::raw_fd_ostream>(
- DiagOpts->DiagnosticLogFile, EC,
+ DiagOpts.DiagnosticLogFile, EC,
llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF);
if (EC) {
Diags.Report(diag::warn_fe_cc_log_diagnostics_failure)
- << DiagOpts->DiagnosticLogFile << EC.message();
+ << DiagOpts.DiagnosticLogFile << EC.message();
} else {
FileOS->SetUnbuffered();
OS = FileOS.get();
@@ -315,7 +315,7 @@ static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
}
}
-static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
+static void SetupSerializedDiagnostics(DiagnosticOptions &DiagOpts,
DiagnosticsEngine &Diags,
StringRef OutputFile) {
auto SerializedConsumer =
@@ -333,12 +333,12 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
void CompilerInstance::createDiagnostics(llvm::vfs::FileSystem &VFS,
DiagnosticConsumer *Client,
bool ShouldOwnClient) {
- Diagnostics = createDiagnostics(VFS, &getDiagnosticOpts(), Client,
+ Diagnostics = createDiagnostics(VFS, getDiagnosticOpts(), Client,
ShouldOwnClient, &getCodeGenOpts());
}
IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
- llvm::vfs::FileSystem &VFS, DiagnosticOptions *Opts,
+ llvm::vfs::FileSystem &VFS, DiagnosticOptions &Opts,
DiagnosticConsumer *Client, bool ShouldOwnClient,
const CodeGenOptions *CodeGenOpts) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
@@ -349,25 +349,24 @@ IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
// implementing -verify.
if (Client) {
Diags->setClient(Client, ShouldOwnClient);
- } else if (Opts->getFormat() == DiagnosticOptions::SARIF) {
+ } else if (Opts.getFormat() == DiagnosticOptions::SARIF) {
Diags->setClient(new SARIFDiagnosticPrinter(llvm::errs(), Opts));
} else
Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), Opts));
// Chain in -verify checker, if requested.
- if (Opts->VerifyDiagnostics)
+ if (Opts.VerifyDiagnostics)
Diags->setClient(new VerifyDiagnosticConsumer(*Diags));
// Chain in -diagnostic-log-file dumper, if requested.
- if (!Opts->DiagnosticLogFile.empty())
+ if (!Opts.DiagnosticLogFile.empty())
SetUpDiagnosticLog(Opts, CodeGenOpts, *Diags);
- if (!Opts->DiagnosticSerializationFile.empty())
- SetupSerializedDiagnostics(Opts, *Diags,
- Opts->DiagnosticSerializationFile);
+ if (!Opts.DiagnosticSerializationFile.empty())
+ SetupSerializedDiagnostics(Opts, *Diags, Opts.DiagnosticSerializationFile);
// Configure our handling of diagnostics.
- ProcessWarningOptions(*Diags, *Opts, VFS);
+ ProcessWarningOptions(*Diags, Opts, VFS);
return Diags;
}
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;
}
diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index d0b855f..99212b8 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -31,11 +31,15 @@ std::unique_ptr<CompilerInvocation>
clang::createInvocation(ArrayRef<const char *> ArgList,
CreateInvocationOptions Opts) {
assert(!ArgList.empty());
- auto Diags = Opts.Diags
- ? std::move(Opts.Diags)
- : CompilerInstance::createDiagnostics(
- Opts.VFS ? *Opts.VFS : *llvm::vfs::getRealFileSystem(),
- new DiagnosticOptions);
+ std::optional<DiagnosticOptions> LocalDiagOpts;
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
+ if (Opts.Diags) {
+ Diags = std::move(Opts.Diags);
+ } else {
+ LocalDiagOpts.emplace();
+ Diags = CompilerInstance::createDiagnostics(
+ Opts.VFS ? *Opts.VFS : *llvm::vfs::getRealFileSystem(), *LocalDiagOpts);
+ }
SmallVector<const char *, 16> Args(ArgList);
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index 3b120ab..1396b2b 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -30,7 +30,7 @@
using namespace clang;
DiagnosticRenderer::DiagnosticRenderer(const LangOptions &LangOpts,
- DiagnosticOptions *DiagOpts)
+ DiagnosticOptions &DiagOpts)
: LangOpts(LangOpts), DiagOpts(DiagOpts), LastLevel() {}
DiagnosticRenderer::~DiagnosticRenderer() = default;
@@ -115,7 +115,7 @@ void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,
// Find the ultimate expansion location for the diagnostic.
Loc = Loc.getFileLoc();
- PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
+ PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts.ShowPresumedLoc);
// First, if this diagnostic is not in the main file, print out the
// "included from" lines.
@@ -172,7 +172,7 @@ void DiagnosticRenderer::emitIncludeStack(FullSourceLoc Loc, PresumedLoc PLoc,
LastIncludeLoc = IncludeLoc;
- if (!DiagOpts->ShowNoteIncludeStack && Level == DiagnosticsEngine::Note)
+ if (!DiagOpts.ShowNoteIncludeStack && Level == DiagnosticsEngine::Note)
return;
if (IncludeLoc.isValid())
@@ -191,7 +191,7 @@ void DiagnosticRenderer::emitIncludeStackRecursively(FullSourceLoc Loc) {
return;
}
- PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
+ PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts.ShowPresumedLoc);
if (PLoc.isInvalid())
return;
@@ -232,7 +232,7 @@ void DiagnosticRenderer::emitImportStackRecursively(FullSourceLoc Loc,
return;
}
- PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
+ PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts.ShowPresumedLoc);
// Emit the other import frames first.
std::pair<FullSourceLoc, StringRef> NextImportLoc = Loc.getModuleImportLoc();
@@ -247,9 +247,8 @@ void DiagnosticRenderer::emitImportStackRecursively(FullSourceLoc Loc,
void DiagnosticRenderer::emitModuleBuildStack(const SourceManager &SM) {
ModuleBuildStack Stack = SM.getModuleBuildStack();
for (const auto &I : Stack) {
- emitBuildingModuleLocation(I.second, I.second.getPresumedLoc(
- DiagOpts->ShowPresumedLoc),
- I.first);
+ emitBuildingModuleLocation(
+ I.second, I.second.getPresumedLoc(DiagOpts.ShowPresumedLoc), I.first);
}
}
@@ -539,7 +538,7 @@ void DiagnosticRenderer::emitMacroExpansions(FullSourceLoc Loc,
LocationStack.begin() + IgnoredEnd);
unsigned MacroDepth = LocationStack.size();
- unsigned MacroLimit = DiagOpts->MacroBacktraceLimit;
+ unsigned MacroLimit = DiagOpts.MacroBacktraceLimit;
if (MacroDepth <= MacroLimit || MacroLimit == 0) {
for (auto I = LocationStack.rbegin(), E = LocationStack.rend();
I != E; ++I)
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 54a2e3e..af9d18a 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -766,9 +766,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics());
// The AST unit populates its own diagnostics engine rather than ours.
- IntrusiveRefCntPtr<DiagnosticsEngine> ASTDiags(
- new DiagnosticsEngine(Diags->getDiagnosticIDs(),
- &Diags->getDiagnosticOptions()));
+ IntrusiveRefCntPtr<DiagnosticsEngine> ASTDiags(new DiagnosticsEngine(
+ Diags->getDiagnosticIDs(), Diags->getDiagnosticOptions()));
ASTDiags->setClient(Diags->getClient(), /*OwnsClient*/false);
// FIXME: What if the input is a memory buffer?
@@ -776,7 +775,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
InputFile, CI.getPCHContainerReader(), ASTUnit::LoadPreprocessorOnly,
- ASTDiags, CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
+ nullptr, ASTDiags, CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
if (!AST)
return false;
@@ -842,8 +841,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
StringRef InputFile = Input.getFile();
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
- InputFile, CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
- CI.getFileSystemOpts(), CI.getHeaderSearchOpts(), &CI.getLangOpts());
+ InputFile, CI.getPCHContainerReader(), ASTUnit::LoadEverything, nullptr,
+ Diags, CI.getFileSystemOpts(), CI.getHeaderSearchOpts(),
+ &CI.getLangOpts());
if (!AST)
return false;
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 8c75e1a..d14d091 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -685,21 +685,21 @@ namespace {
return false;
}
- bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
+ bool ReadDiagnosticOptions(DiagnosticOptions &DiagOpts,
StringRef ModuleFilename,
bool Complain) override {
Out.indent(2) << "Diagnostic options:\n";
-#define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
-#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
- Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
-#define VALUE_DIAGOPT(Name, Bits, Default) \
- Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
+#define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts.Name, #Name);
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+ Out.indent(4) << #Name << ": " << DiagOpts.get##Name() << "\n";
+#define VALUE_DIAGOPT(Name, Bits, Default) \
+ Out.indent(4) << #Name << ": " << DiagOpts.Name << "\n";
#include "clang/Basic/DiagnosticOptions.def"
Out.indent(4) << "Diagnostic flags:\n";
- for (const std::string &Warning : DiagOpts->Warnings)
+ for (const std::string &Warning : DiagOpts.Warnings)
Out.indent(6) << "-W" << Warning << "\n";
- for (const std::string &Remark : DiagOpts->Remarks)
+ for (const std::string &Remark : DiagOpts.Remarks)
Out.indent(6) << "-R" << Remark << "\n";
return false;
diff --git a/clang/lib/Frontend/LogDiagnosticPrinter.cpp b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
index 4e963af..2d18893 100644
--- a/clang/lib/Frontend/LogDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/LogDiagnosticPrinter.cpp
@@ -18,10 +18,10 @@ using namespace clang;
using namespace markup;
LogDiagnosticPrinter::LogDiagnosticPrinter(
- raw_ostream &os, DiagnosticOptions *diags,
+ raw_ostream &os, DiagnosticOptions &DiagOpts,
std::unique_ptr<raw_ostream> StreamOwner)
: OS(os), StreamOwner(std::move(StreamOwner)), LangOpts(nullptr),
- DiagOpts(diags) {}
+ DiagOpts(DiagOpts) {}
static StringRef getLevelName(DiagnosticsEngine::Level Level) {
switch (Level) {
diff --git a/clang/lib/Frontend/SARIFDiagnostic.cpp b/clang/lib/Frontend/SARIFDiagnostic.cpp
index 4e36153..e2aec7f6 100644
--- a/clang/lib/Frontend/SARIFDiagnostic.cpp
+++ b/clang/lib/Frontend/SARIFDiagnostic.cpp
@@ -31,7 +31,7 @@
namespace clang {
SARIFDiagnostic::SARIFDiagnostic(raw_ostream &OS, const LangOptions &LangOpts,
- DiagnosticOptions *DiagOpts,
+ DiagnosticOptions &DiagOpts,
SarifDocumentWriter *Writer)
: DiagnosticRenderer(LangOpts, DiagOpts), Writer(Writer) {}
@@ -163,7 +163,7 @@ SARIFDiagnostic::addDiagnosticLevelToRule(SarifRule Rule,
llvm::StringRef SARIFDiagnostic::emitFilename(StringRef Filename,
const SourceManager &SM) {
- if (DiagOpts->AbsolutePath) {
+ if (DiagOpts.AbsolutePath) {
auto File = SM.getFileManager().getOptionalFileRef(Filename);
if (File) {
// We want to print a simplified absolute path, i. e. without "dots".
diff --git a/clang/lib/Frontend/SARIFDiagnosticPrinter.cpp b/clang/lib/Frontend/SARIFDiagnosticPrinter.cpp
index 73928d1..23fbc3e 100644
--- a/clang/lib/Frontend/SARIFDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/SARIFDiagnosticPrinter.cpp
@@ -26,15 +26,15 @@
namespace clang {
SARIFDiagnosticPrinter::SARIFDiagnosticPrinter(raw_ostream &OS,
- DiagnosticOptions *Diags)
- : OS(OS), DiagOpts(Diags) {}
+ DiagnosticOptions &DiagOpts)
+ : OS(OS), DiagOpts(DiagOpts) {}
void SARIFDiagnosticPrinter::BeginSourceFile(const LangOptions &LO,
const Preprocessor *PP) {
// Build the SARIFDiagnostic utility.
assert(hasSarifWriter() && "Writer not set!");
assert(!SARIFDiag && "SARIFDiagnostic already set.");
- SARIFDiag = std::make_unique<SARIFDiagnostic>(OS, LO, &*DiagOpts, &*Writer);
+ SARIFDiag = std::make_unique<SARIFDiagnostic>(OS, LO, DiagOpts, &*Writer);
// Initialize the SARIF object.
Writer->createRun("clang", Prefix);
}
@@ -72,7 +72,6 @@ void SARIFDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
}
// Assert that the rest of our infrastructure is setup properly.
- assert(DiagOpts && "Unexpected diagnostic without options set");
assert(Info.hasSourceManager() &&
"Unexpected diagnostic with no source manager");
diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
index 02aa3e8..ee49cdd 100644
--- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -57,8 +57,8 @@ class SDiagsRenderer : public DiagnosticNoteRenderer {
SDiagsWriter &Writer;
public:
SDiagsRenderer(SDiagsWriter &Writer, const LangOptions &LangOpts,
- DiagnosticOptions *DiagOpts)
- : DiagnosticNoteRenderer(LangOpts, DiagOpts), Writer(Writer) {}
+ DiagnosticOptions &DiagOpts)
+ : DiagnosticNoteRenderer(LangOpts, DiagOpts), Writer(Writer) {}
~SDiagsRenderer() override {}
@@ -140,7 +140,7 @@ class SDiagsWriter : public DiagnosticConsumer {
State(std::move(State)) {}
public:
- SDiagsWriter(StringRef File, DiagnosticOptions *Diags, bool MergeChildRecords)
+ SDiagsWriter(StringRef File, DiagnosticOptions &Diags, bool MergeChildRecords)
: LangOpts(nullptr), OriginalInstance(true),
MergeChildRecords(MergeChildRecords),
State(std::make_shared<SharedState>(File, Diags)) {
@@ -242,12 +242,12 @@ private:
/// State that is shared among the various clones of this diagnostic
/// consumer.
struct SharedState {
- SharedState(StringRef File, DiagnosticOptions *Diags)
- : DiagOpts(Diags), Stream(Buffer), OutputFile(File.str()),
+ SharedState(StringRef File, DiagnosticOptions &DiagOpts)
+ : DiagOpts(DiagOpts), Stream(Buffer), OutputFile(File.str()),
EmittedAnyDiagBlocks(false) {}
/// Diagnostic options.
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
+ DiagnosticOptions DiagOpts;
/// The byte buffer for the serialized content.
SmallString<1024> Buffer;
@@ -295,9 +295,11 @@ private:
namespace clang {
namespace serialized_diags {
-std::unique_ptr<DiagnosticConsumer>
-create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords) {
- return std::make_unique<SDiagsWriter>(OutputFile, Diags, MergeChildRecords);
+std::unique_ptr<DiagnosticConsumer> create(StringRef OutputFile,
+ DiagnosticOptions &DiagOpts,
+ bool MergeChildRecords) {
+ return std::make_unique<SDiagsWriter>(OutputFile, DiagOpts,
+ MergeChildRecords);
}
} // end namespace serialized_diags
@@ -617,7 +619,7 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
assert(Info.hasSourceManager() && LangOpts &&
"Unexpected diagnostic with valid location outside of a source file");
- SDiagsRenderer Renderer(*this, *LangOpts, &*State->DiagOpts);
+ SDiagsRenderer Renderer(*this, *LangOpts, State->DiagOpts);
Renderer.emitDiagnostic(
FullSourceLoc(Info.getLocation(), Info.getSourceManager()), DiagLevel,
State->diagBuf, Info.getRanges(), Info.getFixItHints(), &Info);
@@ -755,10 +757,9 @@ DiagnosticsEngine *SDiagsWriter::getMetaDiags() {
// normally not be used.
if (!State->MetaDiagnostics) {
IntrusiveRefCntPtr<DiagnosticIDs> IDs(new DiagnosticIDs());
- auto Client =
- new TextDiagnosticPrinter(llvm::errs(), State->DiagOpts.get());
- State->MetaDiagnostics = std::make_unique<DiagnosticsEngine>(
- IDs, State->DiagOpts.get(), Client);
+ auto Client = new TextDiagnosticPrinter(llvm::errs(), State->DiagOpts);
+ State->MetaDiagnostics =
+ std::make_unique<DiagnosticsEngine>(IDs, State->DiagOpts, Client);
}
return State->MetaDiagnostics.get();
}
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 4119ce6..25ab13b 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -654,7 +654,7 @@ static bool printWordWrapped(raw_ostream &OS, StringRef Str, unsigned Columns,
}
TextDiagnostic::TextDiagnostic(raw_ostream &OS, const LangOptions &LangOpts,
- DiagnosticOptions *DiagOpts,
+ DiagnosticOptions &DiagOpts,
const Preprocessor *PP)
: DiagnosticRenderer(LangOpts, DiagOpts), OS(OS), PP(PP) {}
@@ -670,15 +670,15 @@ void TextDiagnostic::emitDiagnosticMessage(
if (Loc.isValid())
emitDiagnosticLoc(Loc, PLoc, Level, Ranges);
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.resetColor();
- if (DiagOpts->ShowLevel)
- printDiagnosticLevel(OS, Level, DiagOpts->ShowColors);
+ if (DiagOpts.ShowLevel)
+ printDiagnosticLevel(OS, Level, DiagOpts.ShowColors);
printDiagnosticMessage(OS,
/*IsSupplemental*/ Level == DiagnosticsEngine::Note,
Message, OS.tell() - StartOfLocationInfo,
- DiagOpts->MessageLength, DiagOpts->ShowColors);
+ DiagOpts.MessageLength, DiagOpts.ShowColors);
}
/*static*/ void
@@ -743,7 +743,7 @@ void TextDiagnostic::emitFilename(StringRef Filename, const SourceManager &SM) {
#ifdef _WIN32
SmallString<4096> TmpFilename;
#endif
- if (DiagOpts->AbsolutePath) {
+ if (DiagOpts.AbsolutePath) {
auto File = SM.getFileManager().getOptionalFileRef(Filename);
if (File) {
// We want to print a simplified absolute path, i. e. without "dots".
@@ -796,27 +796,27 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
}
unsigned LineNo = PLoc.getLine();
- if (!DiagOpts->ShowLocation)
+ if (!DiagOpts.ShowLocation)
return;
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.changeColor(savedColor, true);
emitFilename(PLoc.getFilename(), Loc.getManager());
- switch (DiagOpts->getFormat()) {
+ switch (DiagOpts.getFormat()) {
case DiagnosticOptions::SARIF:
case DiagnosticOptions::Clang:
- if (DiagOpts->ShowLine)
+ if (DiagOpts.ShowLine)
OS << ':' << LineNo;
break;
case DiagnosticOptions::MSVC: OS << '(' << LineNo; break;
case DiagnosticOptions::Vi: OS << " +" << LineNo; break;
}
- if (DiagOpts->ShowColumn)
+ if (DiagOpts.ShowColumn)
// Compute the column number.
if (unsigned ColNo = PLoc.getColumn()) {
- if (DiagOpts->getFormat() == DiagnosticOptions::MSVC) {
+ if (DiagOpts.getFormat() == DiagnosticOptions::MSVC) {
OS << ',';
// Visual Studio 2010 or earlier expects column number to be off by one
if (LangOpts.MSCompatibilityVersion &&
@@ -826,7 +826,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
OS << ':';
OS << ColNo;
}
- switch (DiagOpts->getFormat()) {
+ switch (DiagOpts.getFormat()) {
case DiagnosticOptions::SARIF:
case DiagnosticOptions::Clang:
case DiagnosticOptions::Vi: OS << ':'; break;
@@ -841,7 +841,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
break;
}
- if (DiagOpts->ShowSourceRanges && !Ranges.empty()) {
+ if (DiagOpts.ShowSourceRanges && !Ranges.empty()) {
FileID CaretFileID = Loc.getExpansionLoc().getFileID();
bool PrintedRange = false;
const SourceManager &SM = Loc.getManager();
@@ -881,7 +881,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
}
void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
- if (DiagOpts->ShowLocation && PLoc.isValid()) {
+ if (DiagOpts.ShowLocation && PLoc.isValid()) {
OS << "In file included from ";
emitFilename(PLoc.getFilename(), Loc.getManager());
OS << ':' << PLoc.getLine() << ":\n";
@@ -891,7 +891,7 @@ void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
void TextDiagnostic::emitImportLocation(FullSourceLoc Loc, PresumedLoc PLoc,
StringRef ModuleName) {
- if (DiagOpts->ShowLocation && PLoc.isValid())
+ if (DiagOpts.ShowLocation && PLoc.isValid())
OS << "In module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
@@ -901,7 +901,7 @@ void TextDiagnostic::emitImportLocation(FullSourceLoc Loc, PresumedLoc PLoc,
void TextDiagnostic::emitBuildingModuleLocation(FullSourceLoc Loc,
PresumedLoc PLoc,
StringRef ModuleName) {
- if (DiagOpts->ShowLocation && PLoc.isValid())
+ if (DiagOpts.ShowLocation && PLoc.isValid())
OS << "While building module '" << ModuleName << "' imported from "
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":\n";
else
@@ -998,14 +998,13 @@ static void highlightRange(const LineRange &R, const SourceColumnMap &Map,
std::fill(CaretLine.begin() + StartColNo, CaretLine.begin() + EndColNo, '~');
}
-static std::string buildFixItInsertionLine(FileID FID,
- unsigned LineNo,
+static std::string buildFixItInsertionLine(FileID FID, unsigned LineNo,
const SourceColumnMap &map,
ArrayRef<FixItHint> Hints,
const SourceManager &SM,
- const DiagnosticOptions *DiagOpts) {
+ const DiagnosticOptions &DiagOpts) {
std::string FixItInsertionLine;
- if (Hints.empty() || !DiagOpts->ShowFixits)
+ if (Hints.empty() || !DiagOpts.ShowFixits)
return FixItInsertionLine;
unsigned PrevHintEndCol = 0;
@@ -1057,7 +1056,7 @@ static std::string buildFixItInsertionLine(FileID FID,
}
}
- expandTabs(FixItInsertionLine, DiagOpts->TabStop);
+ expandTabs(FixItInsertionLine, DiagOpts.TabStop);
return FixItInsertionLine;
}
@@ -1296,7 +1295,7 @@ void TextDiagnostic::emitSnippetAndCaret(
// was part of a different warning or error diagnostic, or if the
// diagnostic has ranges. We don't want to emit the same caret
// multiple times if one loc has multiple diagnostics.
- if (!DiagOpts->ShowCarets)
+ if (!DiagOpts.ShowCarets)
return;
if (Loc == LastLoc && Ranges.empty() && Hints.empty() &&
(LastLevel != DiagnosticsEngine::Note || Level == LastLevel))
@@ -1322,7 +1321,7 @@ void TextDiagnostic::emitSnippetAndCaret(
return;
// Find the set of lines to include.
- const unsigned MaxLines = DiagOpts->SnippetLineLimit;
+ const unsigned MaxLines = DiagOpts.SnippetLineLimit;
std::pair<unsigned, unsigned> Lines = {CaretLineNo, CaretLineNo};
unsigned DisplayLineNo = Loc.getPresumedLoc().getLine();
for (const auto &I : Ranges) {
@@ -1338,7 +1337,7 @@ void TextDiagnostic::emitSnippetAndCaret(
// Where [number] is MaxLineNoDisplayWidth columns
// and the full thing is therefore MaxLineNoDisplayWidth + 4 columns.
unsigned MaxLineNoDisplayWidth =
- DiagOpts->ShowLineNumbers
+ DiagOpts.ShowLineNumbers
? std::max(4u, getNumDisplayWidth(DisplayLineNo + MaxLines))
: 0;
auto indentForLineNumbers = [&] {
@@ -1350,7 +1349,7 @@ void TextDiagnostic::emitSnippetAndCaret(
// emit, starting from the first line.
std::unique_ptr<SmallVector<StyleRange>[]> SourceStyles =
highlightLines(BufData, Lines.first, Lines.second, PP, LangOpts,
- DiagOpts->ShowColors, FID, SM);
+ DiagOpts.ShowColors, FID, SM);
SmallVector<LineRange> LineRanges =
prepareAndFilterRanges(Ranges, SM, Lines, FID, LangOpts);
@@ -1382,7 +1381,7 @@ void TextDiagnostic::emitSnippetAndCaret(
SourceLine.pop_back();
// Build the byte to column map.
- const SourceColumnMap sourceColMap(SourceLine, DiagOpts->TabStop);
+ const SourceColumnMap sourceColMap(SourceLine, DiagOpts.TabStop);
std::string CaretLine;
// Highlight all of the characters covered by Ranges with ~ characters.
@@ -1398,12 +1397,12 @@ void TextDiagnostic::emitSnippetAndCaret(
CaretLine[Col] = '^';
}
- std::string FixItInsertionLine = buildFixItInsertionLine(
- FID, LineNo, sourceColMap, Hints, SM, DiagOpts.get());
+ std::string FixItInsertionLine =
+ buildFixItInsertionLine(FID, LineNo, sourceColMap, Hints, SM, DiagOpts);
// If the source line is too long for our terminal, select only the
// "interesting" source region within that line.
- unsigned Columns = DiagOpts->MessageLength;
+ unsigned Columns = DiagOpts.MessageLength;
if (Columns)
selectInterestingSourceRegion(SourceLine, CaretLine, FixItInsertionLine,
Columns, sourceColMap);
@@ -1412,7 +1411,7 @@ void TextDiagnostic::emitSnippetAndCaret(
// to produce easily machine parsable output. Add a space before the
// source line and the caret to make it trivial to tell the main diagnostic
// line from what the user is intended to see.
- if (DiagOpts->ShowSourceRanges && !SourceLine.empty()) {
+ if (DiagOpts.ShowSourceRanges && !SourceLine.empty()) {
SourceLine = ' ' + SourceLine;
CaretLine = ' ' + CaretLine;
}
@@ -1423,22 +1422,22 @@ void TextDiagnostic::emitSnippetAndCaret(
if (!CaretLine.empty()) {
indentForLineNumbers();
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.changeColor(caretColor, true);
OS << CaretLine << '\n';
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.resetColor();
}
if (!FixItInsertionLine.empty()) {
indentForLineNumbers();
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
// Print fixit line in color
OS.changeColor(fixitColor, false);
- if (DiagOpts->ShowSourceRanges)
+ if (DiagOpts.ShowSourceRanges)
OS << ' ';
OS << FixItInsertionLine << '\n';
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.resetColor();
}
}
@@ -1464,10 +1463,10 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
size_t I = 0;
while (I < SourceLine.size()) {
auto [Str, WasPrintable] =
- printableTextForNextCharacter(SourceLine, &I, DiagOpts->TabStop);
+ printableTextForNextCharacter(SourceLine, &I, DiagOpts.TabStop);
// Toggle inverted colors on or off for this character.
- if (DiagOpts->ShowColors) {
+ if (DiagOpts.ShowColors) {
if (WasPrintable == PrintReversed) {
PrintReversed = !PrintReversed;
if (PrintReversed)
@@ -1498,7 +1497,7 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
OS << Str;
}
- if (DiagOpts->ShowColors)
+ if (DiagOpts.ShowColors)
OS.resetColor();
OS << '\n';
@@ -1506,7 +1505,7 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
void TextDiagnostic::emitParseableFixits(ArrayRef<FixItHint> Hints,
const SourceManager &SM) {
- if (!DiagOpts->ShowParseableFixits)
+ if (!DiagOpts.ShowParseableFixits)
return;
// We follow FixItRewriter's example in not (yet) handling
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index 28f7218..e878c63 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -22,11 +22,9 @@
using namespace clang;
TextDiagnosticPrinter::TextDiagnosticPrinter(raw_ostream &os,
- DiagnosticOptions *diags,
+ DiagnosticOptions &DiagOpts,
bool _OwnsOutputStream)
- : OS(os), DiagOpts(diags),
- OwnsOutputStream(_OwnsOutputStream) {
-}
+ : OS(os), DiagOpts(DiagOpts), OwnsOutputStream(_OwnsOutputStream) {}
TextDiagnosticPrinter::~TextDiagnosticPrinter() {
if (OwnsOutputStream)
@@ -36,7 +34,7 @@ TextDiagnosticPrinter::~TextDiagnosticPrinter() {
void TextDiagnosticPrinter::BeginSourceFile(const LangOptions &LO,
const Preprocessor *PP) {
// Build the TextDiagnostic utility.
- TextDiag.reset(new TextDiagnostic(OS, LO, &*DiagOpts, PP));
+ TextDiag.reset(new TextDiagnostic(OS, LO, DiagOpts, PP));
}
void TextDiagnosticPrinter::EndSourceFile() {
@@ -121,7 +119,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
Info.FormatDiagnostic(OutStr);
llvm::raw_svector_ostream DiagMessageStream(OutStr);
- printDiagnosticOptions(DiagMessageStream, Level, Info, *DiagOpts);
+ printDiagnosticOptions(DiagMessageStream, Level, Info, DiagOpts);
// Keeps track of the starting position of the location
// information (e.g., "foo.c:10:4:") that precedes the error
@@ -137,17 +135,16 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,
// diagnostics in a context that lacks language options, a source manager, or
// other infrastructure necessary when emitting more rich diagnostics.
if (!Info.getLocation().isValid()) {
- TextDiagnostic::printDiagnosticLevel(OS, Level, DiagOpts->ShowColors);
+ TextDiagnostic::printDiagnosticLevel(OS, Level, DiagOpts.ShowColors);
TextDiagnostic::printDiagnosticMessage(
OS, /*IsSupplemental=*/Level == DiagnosticsEngine::Note,
DiagMessageStream.str(), OS.tell() - StartOfLocationInfo,
- DiagOpts->MessageLength, DiagOpts->ShowColors);
+ DiagOpts.MessageLength, DiagOpts.ShowColors);
OS.flush();
return;
}
// Assert that the rest of our infrastructure is setup properly.
- assert(DiagOpts && "Unexpected diagnostic without options set");
assert(Info.hasSourceManager() &&
"Unexpected diagnostic with no source manager");
assert(TextDiag && "Unexpected diagnostic outside source file processing");
diff --git a/clang/lib/Interpreter/CodeCompletion.cpp b/clang/lib/Interpreter/CodeCompletion.cpp
index aa90663..dac3888 100644
--- a/clang/lib/Interpreter/CodeCompletion.cpp
+++ b/clang/lib/Interpreter/CodeCompletion.cpp
@@ -359,13 +359,12 @@ void ReplCodeCompleter::codeComplete(CompilerInstance *InterpCI,
unsigned Col,
const CompilerInstance *ParentCI,
std::vector<std::string> &CCResults) {
- auto DiagOpts = DiagnosticOptions();
auto consumer = ReplCompletionConsumer(CCResults, *this);
auto diag = InterpCI->getDiagnosticsPtr();
std::unique_ptr<ASTUnit> AU(ASTUnit::LoadFromCompilerInvocationAction(
InterpCI->getInvocationPtr(), std::make_shared<PCHContainerOperations>(),
- diag));
+ nullptr, diag));
llvm::SmallVector<clang::StoredDiagnostic, 8> sd = {};
llvm::SmallVector<const llvm::MemoryBuffer *, 1> tb = {};
InterpCI->getFrontendOpts().Inputs[0] = FrontendInputFile(
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 4b407a0..84feff8 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -95,9 +95,9 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
// Buffer diagnostics from argument parsing so that we can output them using
// a well formed diagnostic object.
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
+ DiagnosticOptions DiagOpts;
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
- DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
+ DiagnosticsEngine Diags(DiagID, DiagOpts, DiagsBuffer);
bool Success = CompilerInvocation::CreateFromArgs(
Clang->getInvocation(), llvm::ArrayRef(Argv.begin(), Argv.size()), Diags);
@@ -173,10 +173,10 @@ IncrementalCompilerBuilder::create(std::string TT,
// Buffer diagnostics from argument parsing so that we can output them using a
// well formed diagnostic object.
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts =
+ std::unique_ptr<DiagnosticOptions> DiagOpts =
CreateAndPopulateDiagOpts(ClangArgv);
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
- DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
+ DiagnosticsEngine Diags(DiagID, *DiagOpts, DiagsBuffer);
driver::Driver Driver(/*MainBinaryName=*/ClangArgv[0], TT, Diags);
Driver.setCheckInputsExist(false); // the input comes from mem buffers
diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp
index c75835d..1829a4f 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -636,8 +636,8 @@ static void HighlightMacrosImpl(
// Temporarily change the diagnostics object so that we ignore any generated
// diagnostics from this pass.
DiagnosticsEngine TmpDiags(PP.getDiagnostics().getDiagnosticIDs(),
- &PP.getDiagnostics().getDiagnosticOptions(),
- new IgnoringDiagConsumer);
+ PP.getDiagnostics().getDiagnosticOptions(),
+ new IgnoringDiagConsumer);
// FIXME: This is a huge hack; we reuse the input preprocessor because we want
// its state, but we aren't actually changing it (we hope). This should really
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d068f5e1..c113fd7 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -193,8 +193,7 @@ bool ChainedASTReaderListener::ReadTargetOptions(
}
bool ChainedASTReaderListener::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename,
- bool Complain) {
+ DiagnosticOptions &DiagOpts, StringRef ModuleFilename, bool Complain) {
return First->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain) ||
Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
@@ -595,16 +594,16 @@ static Module *getTopImportImplicitModule(ModuleManager &ModuleMgr,
return M;
}
-bool PCHValidator::ReadDiagnosticOptions(
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, StringRef ModuleFilename,
- bool Complain) {
+bool PCHValidator::ReadDiagnosticOptions(DiagnosticOptions &DiagOpts,
+ StringRef ModuleFilename,
+ bool Complain) {
DiagnosticsEngine &ExistingDiags = PP.getDiagnostics();
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(ExistingDiags.getDiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
- new DiagnosticsEngine(DiagIDs, DiagOpts.get()));
+ new DiagnosticsEngine(DiagIDs, DiagOpts));
// This should never fail, because we would have processed these options
// before writing them to an ASTFile.
- ProcessWarningOptions(*Diags, *DiagOpts,
+ ProcessWarningOptions(*Diags, DiagOpts,
PP.getFileManager().getVirtualFileSystem(),
/*Report*/ false);
@@ -6422,17 +6421,17 @@ bool ASTReader::ParseTargetOptions(const RecordData &Record,
bool ASTReader::ParseDiagnosticOptions(const RecordData &Record,
StringRef ModuleFilename, bool Complain,
ASTReaderListener &Listener) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
+ DiagnosticOptions DiagOpts;
unsigned Idx = 0;
-#define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
-#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
- DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
+#define DIAGOPT(Name, Bits, Default) DiagOpts.Name = Record[Idx++];
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+ DiagOpts.set##Name(static_cast<Type>(Record[Idx++]));
#include "clang/Basic/DiagnosticOptions.def"
for (unsigned N = Record[Idx++]; N; --N)
- DiagOpts->Warnings.push_back(ReadString(Record, Idx));
+ DiagOpts.Warnings.push_back(ReadString(Record, Idx));
for (unsigned N = Record[Idx++]; N; --N)
- DiagOpts->Remarks.push_back(ReadString(Record, Idx));
+ DiagOpts.Remarks.push_back(ReadString(Record, Idx));
return Listener.ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
}
diff --git a/clang/lib/Testing/TestAST.cpp b/clang/lib/Testing/TestAST.cpp
index 748f59b..b59a8d5 100644
--- a/clang/lib/Testing/TestAST.cpp
+++ b/clang/lib/Testing/TestAST.cpp
@@ -44,7 +44,7 @@ public:
std::string Text;
llvm::raw_string_ostream OS(Text);
TextDiagnostic Renderer(OS, LangOpts,
- &Info.getDiags()->getDiagnosticOptions());
+ Info.getDiags()->getDiagnosticOptions());
Renderer.emitStoredDiagnostic(Out.back());
ADD_FAILURE() << Text;
}
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index af18194..09596b9 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -243,13 +243,13 @@ std::string GetClangToolCommand() {
static bool stripPositionalArgs(std::vector<const char *> Args,
std::vector<std::string> &Result,
std::string &ErrorMsg) {
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
+ DiagnosticOptions DiagOpts;
llvm::raw_string_ostream Output(ErrorMsg);
- TextDiagnosticPrinter DiagnosticPrinter(Output, &*DiagOpts);
+ TextDiagnosticPrinter DiagnosticPrinter(Output, DiagOpts);
UnusedInputDiagConsumer DiagClient(DiagnosticPrinter);
DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
- &*DiagOpts, &DiagClient, false);
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts,
+ &DiagClient, false);
// The clang executable path isn't required since the jobs the driver builds
// will not be executed.
diff --git a/clang/lib/Tooling/Core/Replacement.cpp b/clang/lib/Tooling/Core/Replacement.cpp
index 92e9859..9e2582e 100644
--- a/clang/lib/Tooling/Core/Replacement.cpp
+++ b/clang/lib/Tooling/Core/Replacement.cpp
@@ -585,9 +585,9 @@ llvm::Expected<std::string> applyAllReplacements(StringRef Code,
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
new llvm::vfs::InMemoryFileSystem);
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
+ DiagnosticOptions DiagOpts;
DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
- new DiagnosticOptions);
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), DiagOpts);
SourceManager SourceMgr(Diagnostics, Files);
Rewriter Rewrite(SourceMgr, LangOptions());
InMemoryFileSystem->addFile(
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index 21eea72..207b0a9 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -642,7 +642,7 @@ llvm::Error DependencyScanningWorker::computeDependencies(
std::string DiagnosticOutput;
llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
auto DiagOpts = createDiagOptions(CommandLine);
- TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, DiagOpts.release());
+ TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, *DiagOpts);
if (computeDependencies(WorkingDirectory, CommandLine, Consumer, Controller,
DiagPrinter, TUBuffer))
@@ -660,7 +660,7 @@ llvm::Error DependencyScanningWorker::computeDependencies(
std::string DiagnosticOutput;
llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
auto DiagOpts = createDiagOptions(CommandLine);
- TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, DiagOpts.release());
+ TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, *DiagOpts);
if (computeDependencies(WorkingDirectory, CommandLine, Consumer, Controller,
DiagPrinter, ModuleName))
@@ -744,7 +744,7 @@ bool DependencyScanningWorker::scanDependencies(
sanitizeDiagOpts(*DiagOpts);
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(FileMgr->getVirtualFileSystem(),
- DiagOpts.release(), &DC,
+ *DiagOpts, &DC,
/*ShouldOwnClient=*/false);
// Although `Diagnostics` are used only for command-line parsing, the
diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp
index 961fc1c..874d44ff 100644
--- a/clang/lib/Tooling/Refactoring.cpp
+++ b/clang/lib/Tooling/Refactoring.cpp
@@ -39,11 +39,11 @@ int RefactoringTool::runAndSave(FrontendActionFactory *ActionFactory) {
}
LangOptions DefaultLangOptions;
- IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
- TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts);
+ DiagnosticOptions DiagOpts;
+ TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
DiagnosticsEngine Diagnostics(
- IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
- &*DiagOpts, &DiagnosticPrinter, false);
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()), DiagOpts,
+ &DiagnosticPrinter, false);
SourceManager Sources(Diagnostics, getFiles());
Rewriter Rewrite(Sources, DefaultLangOptions);
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index 3c72f52..1abd7c7 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -377,17 +377,17 @@ bool ToolInvocation::run() {
// Parse diagnostic options from the driver command-line only if none were
// explicitly set.
- IntrusiveRefCntPtr<DiagnosticOptions> ParsedDiagOpts;
+ std::unique_ptr<DiagnosticOptions> ParsedDiagOpts;
DiagnosticOptions *DiagOpts = this->DiagOpts;
if (!DiagOpts) {
ParsedDiagOpts = CreateAndPopulateDiagOpts(Argv);
DiagOpts = &*ParsedDiagOpts;
}
- TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
+ TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), *DiagOpts);
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics =
CompilerInstance::createDiagnostics(
- Files->getVirtualFileSystem(), &*DiagOpts,
+ Files->getVirtualFileSystem(), *DiagOpts,
DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
// Although `Diagnostics` are used only for command-line parsing, the custom
// `DiagConsumer` might expect a `SourceManager` to be present.
@@ -652,9 +652,9 @@ public:
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
DiagnosticConsumer *DiagConsumer) override {
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCompilerInvocation(
- Invocation, std::move(PCHContainerOps),
+ Invocation, std::move(PCHContainerOps), nullptr,
CompilerInstance::createDiagnostics(Files->getVirtualFileSystem(),
- &Invocation->getDiagnosticOpts(),
+ Invocation->getDiagnosticOpts(),
DiagConsumer,
/*ShouldOwnClient=*/false),
Files);