diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index 2920f7325ed..d3629cecceb 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -804,11 +804,17 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx, c->addDependencyCollector(dep); } +#if LLVM_VERSION_MAJOR >= 21 + auto diag_opts = c->getDiagnosticOpts(); +#else + auto diag_opts = &c->getDiagnosticOpts(); +#endif + clang::DiagnosticsEngine diag { new clang::DiagnosticIDs, - new clang::DiagnosticOptions, + diag_opts, new clang::TextDiagnosticPrinter(diag_log_stream, - &c->getDiagnosticOpts()) + diag_opts) }; #if LLVM_VERSION_MAJOR >= 17 @@ -865,7 +871,7 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx, #endif new clang::TextDiagnosticPrinter( diag_log_stream, - &c->getDiagnosticOpts())); + diag_opts)); c->setTarget(clang::TargetInfo::CreateTargetInfo( #if LLVM_VERSION_MAJOR >= 21