Skip to content

Commit

Permalink
ast-exporter: Work around failing type inference in old LLVM versions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Sep 28, 2022
1 parent 0feb8f3 commit dfb2b10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions c2rust-ast-exporter/src/AstExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
// Copy-pasted from Type::getSveEltType introduced after Clang 10:
// (Not extended for RISCV types
// as they are not available in that version anyway).
#if CLANG_VERSION_MAJOR >= 10
auto ElemType = [&] {
switch (kind) {
default: llvm_unreachable("Unknown builtin SVE type!");
#if CLANG_VERSION_MAJOR >= 10
case BuiltinType::SveInt8: return Ctx.SignedCharTy;
case BuiltinType::SveUint8: return Ctx.UnsignedCharTy;
case BuiltinType::SveBool: return Ctx.UnsignedCharTy;
Expand All @@ -369,13 +369,15 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
case BuiltinType::SveFloat16: return Ctx.Float16Ty;
case BuiltinType::SveFloat32: return Ctx.FloatTy;
case BuiltinType::SveFloat64: return Ctx.DoubleTy;
#endif // CLANG_VERSION_MAJOR >= 10
}
}();
// All the SVE types present in Clang 10 are 128-bit vectors
// (see `AArch64SVEACLETypes.def`), so we can divide 128
// by their element size to get element count.
auto ElemCount = 128 / Context->getTypeSize(ElemType);
#else
llvm_unreachable("LLVM version does not have any vector types");
#endif // CLANG_VERSION_MAJOR >= 10
#endif // CLANG_VERSION_MAJOR >= 11
auto ElemTypeTag = encodeQualType(ElemType);
encodeType(T, TagVectorType,
Expand Down

0 comments on commit dfb2b10

Please sign in to comment.