Use LLVMGetTypeKind
This commit is contained in:
@@ -1460,60 +1460,6 @@ LLVMRustGetDiagInfoKind(LLVMDiagnosticInfoRef DI) {
|
||||
return toRust((DiagnosticKind)unwrap(DI)->getKind());
|
||||
}
|
||||
|
||||
// This is kept distinct from LLVMGetTypeKind, because when
|
||||
// a new type kind is added, the Rust-side enum must be
|
||||
// updated or UB will result.
|
||||
extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
|
||||
switch (unwrap(Ty)->getTypeID()) {
|
||||
case Type::VoidTyID:
|
||||
return LLVMVoidTypeKind;
|
||||
case Type::HalfTyID:
|
||||
return LLVMHalfTypeKind;
|
||||
case Type::FloatTyID:
|
||||
return LLVMFloatTypeKind;
|
||||
case Type::DoubleTyID:
|
||||
return LLVMDoubleTypeKind;
|
||||
case Type::X86_FP80TyID:
|
||||
return LLVMX86_FP80TypeKind;
|
||||
case Type::FP128TyID:
|
||||
return LLVMFP128TypeKind;
|
||||
case Type::PPC_FP128TyID:
|
||||
return LLVMPPC_FP128TypeKind;
|
||||
case Type::LabelTyID:
|
||||
return LLVMLabelTypeKind;
|
||||
case Type::MetadataTyID:
|
||||
return LLVMMetadataTypeKind;
|
||||
case Type::IntegerTyID:
|
||||
return LLVMIntegerTypeKind;
|
||||
case Type::FunctionTyID:
|
||||
return LLVMFunctionTypeKind;
|
||||
case Type::StructTyID:
|
||||
return LLVMStructTypeKind;
|
||||
case Type::ArrayTyID:
|
||||
return LLVMArrayTypeKind;
|
||||
case Type::PointerTyID:
|
||||
return LLVMPointerTypeKind;
|
||||
case Type::FixedVectorTyID:
|
||||
return LLVMVectorTypeKind;
|
||||
case Type::TokenTyID:
|
||||
return LLVMTokenTypeKind;
|
||||
case Type::ScalableVectorTyID:
|
||||
return LLVMScalableVectorTypeKind;
|
||||
case Type::BFloatTyID:
|
||||
return LLVMBFloatTypeKind;
|
||||
case Type::X86_AMXTyID:
|
||||
return LLVMX86_AMXTypeKind;
|
||||
default: {
|
||||
std::string error;
|
||||
auto stream = llvm::raw_string_ostream(error);
|
||||
stream << "Rust does not support the TypeID: " << unwrap(Ty)->getTypeID()
|
||||
<< " for the type: " << *unwrap(Ty);
|
||||
stream.flush();
|
||||
report_fatal_error(error.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef)
|
||||
|
||||
extern "C" LLVMSMDiagnosticRef LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
|
||||
|
||||
Reference in New Issue
Block a user