@@ -984,10 +984,11 @@ bool ClangImporter::canReadPCH(StringRef PCHFilename) {
984984 // will try to free it.
985985 invocation->getPreprocessorOpts ().RemappedFileBuffers .clear ();
986986
987+ clang::DiagnosticOptions diagOpts;
987988 CI.setInvocation (std::move (invocation));
988989 CI.setTarget (&Impl.Instance ->getTarget ());
989990 CI.setDiagnostics (&*clang::CompilerInstance::createDiagnostics (
990- Impl.Instance ->getVirtualFileSystem (), new clang::DiagnosticOptions () ));
991+ Impl.Instance ->getVirtualFileSystem (), diagOpts ));
991992
992993 // Note: Reusing the file manager is safe; this is a component that's already
993994 // reused when building PCM files for the module cache.
@@ -1139,13 +1140,11 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
11391140 //
11401141 // The long-term client for Clang diagnostics is set up afterwards, after the
11411142 // clang::CompilerInstance is created.
1142- llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> tempDiagOpts{
1143- new clang::DiagnosticOptions};
1144- auto *tempDiagClient =
1145- new ClangDiagnosticConsumer (Impl, *tempDiagOpts,
1146- ctx.ClangImporterOpts .DumpClangDiagnostics );
1143+ clang::DiagnosticOptions tempDiagOpts;
1144+ auto *tempDiagClient = new ClangDiagnosticConsumer (
1145+ Impl, tempDiagOpts, ctx.ClangImporterOpts .DumpClangDiagnostics );
11471146 auto clangDiags = clang::CompilerInstance::createDiagnostics (
1148- *VFS, tempDiagOpts. get () , tempDiagClient,
1147+ *VFS, tempDiagOpts, tempDiagClient,
11491148 /* owned*/ true );
11501149
11511150 // If using direct cc1 module build, use extra args to setup ClangImporter.
@@ -1265,10 +1264,10 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
12651264 // option here is either generated by dependency scanner or just round tripped
12661265 // from `getClangCC1Arguments` so we don't expect it to fail. Use a simple
12671266 // printing diagnostics consumer for debugging any unexpected error.
1268- auto diagOpts = llvm::makeIntrusiveRefCnt< clang::DiagnosticOptions>() ;
1267+ clang::DiagnosticOptions diagOpts ;
12691268 clang::DiagnosticsEngine clangDiags (
12701269 new clang::DiagnosticIDs (), diagOpts,
1271- new clang::TextDiagnosticPrinter (llvm::errs (), diagOpts. get () ));
1270+ new clang::TextDiagnosticPrinter (llvm::errs (), diagOpts));
12721271
12731272 // Finally, use the CC1 command-line and the diagnostic engine
12741273 // to instantiate our Invocation.
@@ -4161,8 +4160,8 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args() const {
41614160 });
41624161
41634162 clang::CompilerInvocation instance;
4164- clang::DiagnosticsEngine clangDiags ( new clang::DiagnosticIDs (),
4165- new clang::DiagnosticOptions () ,
4163+ clang::DiagnosticOptions diagOpts;
4164+ clang::DiagnosticsEngine clangDiags ( new clang::DiagnosticIDs (), diagOpts ,
41664165 new clang::IgnoringDiagConsumer ());
41674166 bool success = clang::CompilerInvocation::CreateFromArgs (instance, clangArgs,
41684167 clangDiags);
0 commit comments