diff --git a/include/swift/ClangImporter/ClangImporter.h b/include/swift/ClangImporter/ClangImporter.h index 2a52def34eea..2f18b5df574b 100644 --- a/include/swift/ClangImporter/ClangImporter.h +++ b/include/swift/ClangImporter/ClangImporter.h @@ -214,8 +214,7 @@ class ClangImporter final : public ClangModuleLoader { std::vector getClangDepScanningInvocationArguments(ASTContext &ctx); - static std::pair, - std::unique_ptr> + static std::unique_ptr createClangInvocation(ClangImporter *importer, const ClangImporterOptions &importerOpts, llvm::IntrusiveRefCntPtr VFS, diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index a3919ae483e1..701711918c52 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1284,9 +1284,7 @@ std::optional> ClangImporter::getClangCC1Arguments( return CI->getCC1CommandLine(); } -std::pair, - std::unique_ptr> -ClangImporter::createClangInvocation( +std::unique_ptr ClangImporter::createClangInvocation( ClangImporter *importer, const ClangImporterOptions &importerOpts, llvm::IntrusiveRefCntPtr VFS, const std::vector &CC1Args) { @@ -1300,19 +1298,19 @@ 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 = std::make_unique(); + clang::DiagnosticOptions diagOpts; clang::DiagnosticsEngine clangDiags( - new clang::DiagnosticIDs(), *diagOpts, - new clang::TextDiagnosticPrinter(llvm::errs(), *diagOpts)); + new clang::DiagnosticIDs(), diagOpts, + new clang::TextDiagnosticPrinter(llvm::errs(), diagOpts)); // Finally, use the CC1 command-line and the diagnostic engine // to instantiate our Invocation. auto CI = std::make_unique(); if (!clang::CompilerInvocation::CreateFromArgs( *CI, invocationArgs, clangDiags, importerOpts.clangPath.c_str())) - return {nullptr, nullptr}; + return nullptr; - return {std::move(CI), std::move(diagOpts)}; + return CI; } std::unique_ptr ClangImporter::create( @@ -1360,9 +1358,8 @@ std::unique_ptr ClangImporter::create( [] { llvm::errs() << "' '"; }); llvm::errs() << "'\n"; } - std::tie(importer->Impl.Invocation, importer->Impl.DiagnosticOptions) = - createClangInvocation(importer.get(), importerOpts, VFS, - importer->Impl.ClangArgs); + importer->Impl.Invocation = createClangInvocation( + importer.get(), importerOpts, VFS, importer->Impl.ClangArgs); if (!importer->Impl.Invocation) return nullptr; } @@ -1438,7 +1435,7 @@ std::unique_ptr ClangImporter::create( ctx, instance.getVirtualFileSystemPtr(), true); if (!swiftTargetClangArgs) return nullptr; - auto [swiftTargetClangInvocation, clangDiagOpts] = createClangInvocation( + auto swiftTargetClangInvocation = createClangInvocation( importer.get(), importerOpts, instance.getVirtualFileSystemPtr(), *swiftTargetClangArgs); if (!swiftTargetClangInvocation) diff --git a/lib/ClangImporter/ImporterImpl.h b/lib/ClangImporter/ImporterImpl.h index a241abaf0375..cfdc97e0bef0 100644 --- a/lib/ClangImporter/ImporterImpl.h +++ b/lib/ClangImporter/ImporterImpl.h @@ -551,9 +551,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation /// Clang arguments used to create the Clang invocation. std::vector ClangArgs; - /// Clang diagnostic options used to create the Clang invocation. - std::unique_ptr DiagnosticOptions; - /// Mapping from Clang swift_attr attribute text to the Swift source file(s) /// that contain that attribute text. ///