Skip to content

Commit b1e749d

Browse files
committed
Fix building under clang-22
1 parent 4afbdd9 commit b1e749d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

ThunkLibs/Generator/analysis.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,12 @@ void AnalysisAction::ParseInterface(clang::ASTContext& context) {
313313
}
314314

315315
// Get or add parent type to list of structure types
316+
#if CLANG_VERSION_MAJOR >= 22
317+
auto parent_qt = context.getTagType(clang::ElaboratedTypeKeyword::None, std::nullopt, annotated_member->getParent(), false);
318+
auto repack_info_it = types.emplace(context.getCanonicalType(parent_qt).getTypePtr(), RepackedType {}).first;
319+
#else
316320
auto repack_info_it = types.emplace(context.getCanonicalType(annotated_member->getParent()->getTypeForDecl()), RepackedType {}).first;
321+
#endif
317322
if (repack_info_it->second.assumed_compatible) {
318323
throw report_error(template_arg_loc, "May not annotate members of opaque types");
319324
}
@@ -498,7 +503,7 @@ void AnalysisAction::ParseInterface(clang::ASTContext& context) {
498503
// Convert variadic argument list into a count + pointer pair
499504
data.param_types.push_back(context.getSizeType());
500505
data.param_types.push_back(context.getPointerType(*annotations.uniform_va_type));
501-
types.emplace(context.getSizeType()->getTypePtr(), RepackedType {});
506+
types.emplace(context.getSizeType().getTypePtr(), RepackedType {});
502507
if (!annotations.uniform_va_type.value()->isVoidPointerType()) {
503508
types.emplace(annotations.uniform_va_type->getTypePtr(), RepackedType {});
504509
}

ThunkLibs/Generator/gen.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "diagnostics.h"
44
#include "interface.h"
55
#include <clang/Frontend/CompilerInstance.h>
6+
#include <clang/Basic/DiagnosticOptions.h>
67

78
#include <fstream>
89
#include <numeric>
@@ -816,7 +817,11 @@ bool GenerateThunkLibsActionFactory::runInvocation(std::shared_ptr<clang::Compil
816817

817818
GenerateThunkLibsAction Action(libname, output_filenames, abi);
818819

819-
#if LLVM_VERSION_MAJOR >= 20
820+
#if LLVM_VERSION_MAJOR >= 22
821+
auto Diags = clang::CompilerInstance::createDiagnostics(
822+
Compiler.getVirtualFileSystem(), Compiler.getDiagnosticOpts(), DiagConsumer, false);
823+
Compiler.setDiagnostics(std::move(Diags));
824+
#elif LLVM_VERSION_MAJOR >= 20
820825
Compiler.createDiagnostics(Compiler.getVirtualFileSystem(), DiagConsumer, false);
821826
#else
822827
Compiler.createDiagnostics(DiagConsumer, false);
@@ -825,7 +830,11 @@ bool GenerateThunkLibsActionFactory::runInvocation(std::shared_ptr<clang::Compil
825830
return false;
826831
}
827832

833+
#if LLVM_VERSION_MAJOR >= 22
834+
Compiler.createSourceManager();
835+
#else
828836
Compiler.createSourceManager(*Files);
837+
#endif
829838

830839
const bool Success = Compiler.ExecuteAction(Action);
831840

0 commit comments

Comments
 (0)