Skip to content

Commit 8c5c96a

Browse files
Fix a build failure with clang21 (#5369)
The build error message: src/cc/frontends/clang/loader.cc:400:73: error: no matching function for call to ‘clang::TextDiagnosticPrinter::TextDiagnosticPrinter( llvm::raw_fd_ostream&, clang::DiagnosticOptions*)’ 400 | auto diag_client = new TextDiagnosticPrinter(llvm::errs(), &*diag_opts); | ^ The llvm commit llvm/llvm-project#139584 caused the build failure. Adjust the code properly and the error is fixed.
1 parent b8b76e9 commit 8c5c96a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/cc/frontends/clang/loader.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,19 @@ int ClangLoader::do_compile(
396396
flags_cstr_rem.end());
397397

398398
// set up the error reporting class
399+
#if LLVM_VERSION_MAJOR >= 21
400+
DiagnosticOptions diag_opts;
401+
auto diag_client = new TextDiagnosticPrinter(llvm::errs(), diag_opts);
402+
403+
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
404+
DiagnosticsEngine diags(DiagID, diag_opts, diag_client);
405+
#else
399406
IntrusiveRefCntPtr<DiagnosticOptions> diag_opts(new DiagnosticOptions());
400407
auto diag_client = new TextDiagnosticPrinter(llvm::errs(), &*diag_opts);
401408

402409
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
403410
DiagnosticsEngine diags(DiagID, &*diag_opts, diag_client);
411+
#endif
404412

405413
// set up the command line argument wrapper
406414

0 commit comments

Comments
 (0)