upgrade llvm@22
This commit is contained in:
@@ -113,7 +113,10 @@ buildCompilerInstance(const char *filename,
|
||||
const llvm::SmallVectorImpl<const char *> &extra_flags,
|
||||
char **out_error)
|
||||
{
|
||||
auto diagOpts = new clang::DiagnosticOptions();
|
||||
// LLVM 21+: DiagnosticOptions is a plain value passed by reference (no
|
||||
// longer an IntrusiveRefCntPtr). It must outlive `diags` — both are locals
|
||||
// in this scope, declared opts-before-engine, so destruction order is safe.
|
||||
clang::DiagnosticOptions diagOpts;
|
||||
auto diagIDs = new clang::DiagnosticIDs();
|
||||
clang::DiagnosticsEngine diags(diagIDs, diagOpts,
|
||||
new clang::IgnoringDiagConsumer());
|
||||
@@ -128,7 +131,7 @@ buildCompilerInstance(const char *filename,
|
||||
driver_args.push_back("-w");
|
||||
|
||||
#ifdef SX_LLVM_PREFIX
|
||||
static std::string resource_dir = std::string(SX_LLVM_PREFIX) + "/lib/clang/19";
|
||||
static std::string resource_dir = std::string(SX_LLVM_PREFIX) + "/lib/clang/22";
|
||||
driver_args.push_back("-resource-dir");
|
||||
driver_args.push_back(resource_dir.c_str());
|
||||
|
||||
@@ -164,8 +167,10 @@ buildCompilerInstance(const char *filename,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto CI = std::make_unique<clang::CompilerInstance>();
|
||||
CI->setInvocation(std::move(invocation));
|
||||
// LLVM 21+: setInvocation() was removed — the invocation is constructor-
|
||||
// injected instead. createDiagnostics(DiagnosticConsumer*) still exists as
|
||||
// the convenience overload (it builds a default VFS internally).
|
||||
auto CI = std::make_unique<clang::CompilerInstance>(std::move(invocation));
|
||||
CI->createDiagnostics(new clang::IgnoringDiagConsumer());
|
||||
return CI;
|
||||
}
|
||||
@@ -283,8 +288,9 @@ extern "C" LLVMMemoryBufferRef sx_clang_compile_to_object(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Compile LLVM module to native object code
|
||||
std::string triple = mod->getTargetTriple();
|
||||
// Compile LLVM module to native object code.
|
||||
// LLVM 21+: getTargetTriple() returns a const Triple& (was std::string).
|
||||
const llvm::Triple &triple = mod->getTargetTriple();
|
||||
std::string err_str;
|
||||
const llvm::Target *target = llvm::TargetRegistry::lookupTarget(triple, err_str);
|
||||
if (!target) {
|
||||
|
||||
Reference in New Issue
Block a user