[llvm] 5239657 - Use llvm_unreachable for unsupported integer types.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 8 09:59:34 PDT 2021


Author: Simon Pilgrim
Date: 2021-06-08T17:59:05+01:00
New Revision: 52396577a2d85ef1b18f86e643fe3b1033750e15

URL: https://github.com/llvm/llvm-project/commit/52396577a2d85ef1b18f86e643fe3b1033750e15
DIFF: https://github.com/llvm/llvm-project/commit/52396577a2d85ef1b18f86e643fe3b1033750e15.diff

LOG: Use llvm_unreachable for unsupported integer types.

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.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 8d4a198f90c77..c3ba5ebb36fb9 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -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;


        


More information about the llvm-commits mailing list