[llvm-branch-commits] [clang] clang: Use a switch over APFloat semantics instead of if chain (PR #207213)
Erich Keane via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 2 09:08:36 PDT 2026
================
@@ -301,21 +301,24 @@ void CodeGenTypes::RefreshTypeCacheForClass(const CXXRecordDecl *RD) {
static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
const llvm::fltSemantics &format) {
- if (&format == &llvm::APFloat::IEEEhalf())
+ switch (llvm::APFloat::SemanticsToEnum(format)) {
+ case llvm::APFloat::S_IEEEhalf:
return llvm::Type::getHalfTy(VMContext);
- if (&format == &llvm::APFloat::BFloat())
+ case llvm::APFloat::S_BFloat:
return llvm::Type::getBFloatTy(VMContext);
- if (&format == &llvm::APFloat::IEEEsingle())
+ case llvm::APFloat::S_IEEEsingle:
return llvm::Type::getFloatTy(VMContext);
- if (&format == &llvm::APFloat::IEEEdouble())
+ case llvm::APFloat::S_IEEEdouble:
return llvm::Type::getDoubleTy(VMContext);
- if (&format == &llvm::APFloat::IEEEquad())
+ case llvm::APFloat::S_IEEEquad:
return llvm::Type::getFP128Ty(VMContext);
- if (&format == &llvm::APFloat::PPCDoubleDouble())
+ case llvm::APFloat::S_PPCDoubleDouble:
return llvm::Type::getPPC_FP128Ty(VMContext);
- if (&format == &llvm::APFloat::x87DoubleExtended())
+ case llvm::APFloat::S_x87DoubleExtended:
----------------
erichkeane wrote:
Huh! There is a shockingly large list of these that we don't have. Can we add all of these to the 'case' statement instead of 'default' to make sure this switch covers everything?
https://github.com/llvm/llvm-project/pull/207213
More information about the llvm-branch-commits
mailing list