Skip to content

Commit dfb2b10

Browse files
committed
ast-exporter: Work around failing type inference in old LLVM versions
1 parent 0feb8f3 commit dfb2b10

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

c2rust-ast-exporter/src/AstExporter.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,10 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
353353
// Copy-pasted from Type::getSveEltType introduced after Clang 10:
354354
// (Not extended for RISCV types
355355
// as they are not available in that version anyway).
356+
#if CLANG_VERSION_MAJOR >= 10
356357
auto ElemType = [&] {
357358
switch (kind) {
358359
default: llvm_unreachable("Unknown builtin SVE type!");
359-
#if CLANG_VERSION_MAJOR >= 10
360360
case BuiltinType::SveInt8: return Ctx.SignedCharTy;
361361
case BuiltinType::SveUint8: return Ctx.UnsignedCharTy;
362362
case BuiltinType::SveBool: return Ctx.UnsignedCharTy;
@@ -369,13 +369,15 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
369369
case BuiltinType::SveFloat16: return Ctx.Float16Ty;
370370
case BuiltinType::SveFloat32: return Ctx.FloatTy;
371371
case BuiltinType::SveFloat64: return Ctx.DoubleTy;
372-
#endif // CLANG_VERSION_MAJOR >= 10
373372
}
374373
}();
375374
// All the SVE types present in Clang 10 are 128-bit vectors
376375
// (see `AArch64SVEACLETypes.def`), so we can divide 128
377376
// by their element size to get element count.
378377
auto ElemCount = 128 / Context->getTypeSize(ElemType);
378+
#else
379+
llvm_unreachable("LLVM version does not have any vector types");
380+
#endif // CLANG_VERSION_MAJOR >= 10
379381
#endif // CLANG_VERSION_MAJOR >= 11
380382
auto ElemTypeTag = encodeQualType(ElemType);
381383
encodeType(T, TagVectorType,

0 commit comments

Comments
 (0)