mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Adjust calls to clang::DiagnosticsEngine ctor (now takes ref vs. ptr)
See https://github.com/llvm/llvm-project/pull/139584
This commit is contained in:
@@ -145,8 +145,8 @@ void printTripleInfo(const CompilerInvocation &invocation,
|
||||
out << " \"arch\": \"" << swift::getMajorArchitectureName(triple)
|
||||
<< "\",\n";
|
||||
|
||||
clang::DiagnosticsEngine DE{new clang::DiagnosticIDs(),
|
||||
new clang::DiagnosticOptions(),
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
clang::DiagnosticsEngine DE{new clang::DiagnosticIDs(), diagOpts,
|
||||
new clang::IgnoringDiagConsumer()};
|
||||
|
||||
clang::TargetOptions targetOpts;
|
||||
|
||||
@@ -34,10 +34,8 @@ namespace {
|
||||
|
||||
public:
|
||||
ClangDiagRenderer(const clang::LangOptions &langOpts,
|
||||
clang::DiagnosticOptions *diagOpts,
|
||||
decltype(callback) fn)
|
||||
: DiagnosticNoteRenderer(langOpts, diagOpts),
|
||||
callback(fn) {}
|
||||
clang::DiagnosticOptions &diagOpts, decltype(callback) fn)
|
||||
: DiagnosticNoteRenderer(langOpts, diagOpts), callback(fn) {}
|
||||
|
||||
private:
|
||||
/// Is this a diagnostic that doesn't do the user any good to show if it
|
||||
@@ -107,10 +105,9 @@ namespace {
|
||||
|
||||
ClangDiagnosticConsumer::ClangDiagnosticConsumer(
|
||||
ClangImporter::Implementation &impl,
|
||||
clang::DiagnosticOptions &clangDiagOptions,
|
||||
bool dumpToStderr)
|
||||
: TextDiagnosticPrinter(llvm::errs(), &clangDiagOptions),
|
||||
ImporterImpl(impl), DumpToStderr(dumpToStderr) {}
|
||||
clang::DiagnosticOptions &clangDiagOptions, bool dumpToStderr)
|
||||
: TextDiagnosticPrinter(llvm::errs(), clangDiagOptions), ImporterImpl(impl),
|
||||
DumpToStderr(dumpToStderr) {}
|
||||
|
||||
void ClangDiagnosticConsumer::HandleDiagnostic(
|
||||
clang::DiagnosticsEngine::Level clangDiagLevel,
|
||||
@@ -179,7 +176,7 @@ void ClangDiagnosticConsumer::HandleDiagnostic(
|
||||
assert(clangDiag.hasSourceManager());
|
||||
auto clangCI = ImporterImpl.getClangInstance();
|
||||
ClangDiagRenderer renderer(clangCI->getLangOpts(),
|
||||
&clangCI->getDiagnosticOpts(), emitDiag);
|
||||
clangCI->getDiagnosticOpts(), emitDiag);
|
||||
clang::FullSourceLoc clangDiagLoc(clangDiag.getLocation(),
|
||||
clangDiag.getSourceManager());
|
||||
renderer.emitDiagnostic(clangDiagLoc, clangDiagLevel, message,
|
||||
|
||||
@@ -984,10 +984,11 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
|
||||
// will try to free it.
|
||||
invocation->getPreprocessorOpts().RemappedFileBuffers.clear();
|
||||
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
CI.setInvocation(std::move(invocation));
|
||||
CI.setTarget(&Impl.Instance->getTarget());
|
||||
CI.setDiagnostics(&*clang::CompilerInstance::createDiagnostics(
|
||||
Impl.Instance->getVirtualFileSystem(), new clang::DiagnosticOptions()));
|
||||
Impl.Instance->getVirtualFileSystem(), diagOpts));
|
||||
|
||||
// Note: Reusing the file manager is safe; this is a component that's already
|
||||
// reused when building PCM files for the module cache.
|
||||
@@ -1139,13 +1140,11 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
|
||||
//
|
||||
// The long-term client for Clang diagnostics is set up afterwards, after the
|
||||
// clang::CompilerInstance is created.
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
|
||||
new clang::DiagnosticOptions};
|
||||
auto *tempDiagClient =
|
||||
new ClangDiagnosticConsumer(Impl, *tempDiagOpts,
|
||||
ctx.ClangImporterOpts.DumpClangDiagnostics);
|
||||
clang::DiagnosticOptions tempDiagOpts;
|
||||
auto *tempDiagClient = new ClangDiagnosticConsumer(
|
||||
Impl, tempDiagOpts, ctx.ClangImporterOpts.DumpClangDiagnostics);
|
||||
auto clangDiags = clang::CompilerInstance::createDiagnostics(
|
||||
*VFS, tempDiagOpts.get(), tempDiagClient,
|
||||
*VFS, tempDiagOpts, tempDiagClient,
|
||||
/*owned*/ true);
|
||||
|
||||
// If using direct cc1 module build, use extra args to setup ClangImporter.
|
||||
@@ -1265,10 +1264,10 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
|
||||
// option here is either generated by dependency scanner or just round tripped
|
||||
// from `getClangCC1Arguments` so we don't expect it to fail. Use a simple
|
||||
// printing diagnostics consumer for debugging any unexpected error.
|
||||
auto diagOpts = llvm::makeIntrusiveRefCnt<clang::DiagnosticOptions>();
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
clang::DiagnosticsEngine clangDiags(
|
||||
new clang::DiagnosticIDs(), diagOpts,
|
||||
new clang::TextDiagnosticPrinter(llvm::errs(), diagOpts.get()));
|
||||
new clang::TextDiagnosticPrinter(llvm::errs(), diagOpts));
|
||||
|
||||
// Finally, use the CC1 command-line and the diagnostic engine
|
||||
// to instantiate our Invocation.
|
||||
@@ -4161,8 +4160,8 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args() const {
|
||||
});
|
||||
|
||||
clang::CompilerInvocation instance;
|
||||
clang::DiagnosticsEngine clangDiags(new clang::DiagnosticIDs(),
|
||||
new clang::DiagnosticOptions(),
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
clang::DiagnosticsEngine clangDiags(new clang::DiagnosticIDs(), diagOpts,
|
||||
new clang::IgnoringDiagConsumer());
|
||||
bool success = clang::CompilerInvocation::CreateFromArgs(instance, clangArgs,
|
||||
clangDiags);
|
||||
|
||||
@@ -130,9 +130,10 @@ ClangImporter::createClangDriver(
|
||||
|
||||
auto diagVFS = vfs ? vfs : llvm::vfs::getRealFileSystem();
|
||||
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
auto *silentDiagConsumer = new clang::DiagnosticConsumer();
|
||||
auto clangDiags = clang::CompilerInstance::createDiagnostics(
|
||||
*diagVFS, new clang::DiagnosticOptions(), silentDiagConsumer);
|
||||
*diagVFS, diagOpts, silentDiagConsumer);
|
||||
clang::driver::Driver clangDriver(ClangImporterOpts.clangPath,
|
||||
LangOpts.Target.str(), *clangDiags,
|
||||
"clang LLVM compiler", vfs);
|
||||
|
||||
@@ -228,8 +228,8 @@ void ClangImporter::getBridgingHeaderOptions(
|
||||
// Round-trip clang args to canonicalize and clear the options that swift
|
||||
// compiler doesn't need.
|
||||
clang::CompilerInvocation depsInvocation;
|
||||
clang::DiagnosticsEngine clangDiags(new clang::DiagnosticIDs(),
|
||||
new clang::DiagnosticOptions(),
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
clang::DiagnosticsEngine clangDiags(new clang::DiagnosticIDs(), diagOpts,
|
||||
new clang::IgnoringDiagConsumer());
|
||||
|
||||
llvm::SmallVector<const char *> clangArgs;
|
||||
|
||||
@@ -267,15 +267,12 @@ bool ide::initCompilerInvocation(
|
||||
bool ide::initInvocationByClangArguments(ArrayRef<const char *> ArgList,
|
||||
CompilerInvocation &Invok,
|
||||
std::string &Error) {
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts{
|
||||
new clang::DiagnosticOptions()
|
||||
};
|
||||
|
||||
const auto VFS = llvm::vfs::getRealFileSystem();
|
||||
|
||||
clang::TextDiagnosticBuffer DiagBuf;
|
||||
clang::DiagnosticOptions DiagOpts;
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> ClangDiags =
|
||||
clang::CompilerInstance::createDiagnostics(*VFS, DiagOpts.get(), &DiagBuf,
|
||||
clang::CompilerInstance::createDiagnostics(*VFS, DiagOpts, &DiagBuf,
|
||||
/*ShouldOwnClient=*/false);
|
||||
|
||||
// Clang expects this to be like an actual command line. So we need to pass in
|
||||
|
||||
@@ -191,11 +191,11 @@ bool Migrator::performSyntacticPasses(SyntacticPassOptions Opts) {
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> DummyClangDiagIDs {
|
||||
new clang::DiagnosticIDs()
|
||||
};
|
||||
auto ClangDiags =
|
||||
std::make_unique<clang::DiagnosticsEngine>(DummyClangDiagIDs,
|
||||
new clang::DiagnosticOptions,
|
||||
new clang::DiagnosticConsumer(),
|
||||
/*ShouldOwnClient=*/true);
|
||||
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
auto ClangDiags = std::make_unique<clang::DiagnosticsEngine>(
|
||||
DummyClangDiagIDs, diagOpts, new clang::DiagnosticConsumer(),
|
||||
/*ShouldOwnClient=*/true);
|
||||
|
||||
clang::SourceManager ClangSourceManager { *ClangDiags, ClangFileManager };
|
||||
clang::LangOptions ClangLangOpts;
|
||||
|
||||
Reference in New Issue
Block a user