Use llvm_unreachable for unsupported integer types.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 8 Jun 2021 16:33:59 +0000 (17:33 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 8 Jun 2021 16:59:05 +0000 (17:59 +0100)
As suggested on rG937c4cffd024, use llvm_unreachable for unhandled integer types (which shouldn't be possible) instead of breaking and dropping down to the existing fatal error handler.

Helps silence static analyzer warnings.

llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp

index 8d4a198..c3ba5eb 100644 (file)
@@ -130,6 +130,7 @@ static ffi_type *ffiTypeFor(Type *Ty) {
         case 32: return &ffi_type_sint32;
         case 64: return &ffi_type_sint64;
       }
+      llvm_unreachable("Unhandled integer type bitwidth");
     case Type::FloatTyID:   return &ffi_type_float;
     case Type::DoubleTyID:  return &ffi_type_double;
     case Type::PointerTyID: return &ffi_type_pointer;
@@ -166,7 +167,7 @@ static void *ffiValueFor(Type *Ty, const GenericValue &AV,
           return ArgDataPtr;
         }
       }
-      break;
+      llvm_unreachable("Unhandled integer type bitwidth");
     case Type::FloatTyID: {
       float *FloatPtr = (float *) ArgDataPtr;
       *FloatPtr = AV.FloatVal;