Update the C bindings to keep the LLVMTypeKind up to date between the C/C++
authorChris Lattner <sabre@nondot.org>
Wed, 15 Jul 2009 22:00:31 +0000 (22:00 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Jul 2009 22:00:31 +0000 (22:00 +0000)
stuff.  Patch by Zoltan Varga!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75842 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Core.h
include/llvm/Type.h
lib/VMCore/Core.cpp

index a22d12ed86f4cdbce6365e38f4f1bb75164e094f..d723d11111afb87e825bf866f64ec395e896ae49 100644 (file)
@@ -115,7 +115,8 @@ typedef enum {
   LLVMArrayTypeKind,       /**< Arrays */
   LLVMPointerTypeKind,     /**< Pointers */
   LLVMOpaqueTypeKind,      /**< Opaque: type with unknown structure */
-  LLVMVectorTypeKind       /**< SIMD 'packed' format, or other vector type */
+  LLVMVectorTypeKind,      /**< SIMD 'packed' format, or other vector type */
+  LLVMMetadataTypeKind     /**< Metadata */
 } LLVMTypeKind;
 
 typedef enum {
index 38c4e30539fb00d125a0028c26da70ad72c63b96..c311dbedc71cd56f5c34a9516cdf867e60dabb53 100644 (file)
@@ -66,6 +66,7 @@ public:
   /// value, you can cast to a "DerivedType" subclass (see DerivedTypes.h)
   /// Note: If you add an element to this, you need to add an element to the
   /// Type::getPrimitiveType function, or else things will break!
+  /// Also update LLVMTypeKind and LLVMGetTypeKind () in the C binding.
   ///
   enum TypeID {
     // PrimitiveTypes .. make sure LastPrimitiveTyID stays up to date
index d04701e146c162aed0a16f8ea93d1c02aebefe44..600bda6fa572a23237a864479b2fb95f22e04121 100644 (file)
@@ -117,7 +117,40 @@ void LLVMDumpModule(LLVMModuleRef M) {
 /*--.. Operations on all types (mostly) ....................................--*/
 
 LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
-  return static_cast<LLVMTypeKind>(unwrap(Ty)->getTypeID());
+  switch (unwrap(Ty)->getTypeID()) {
+  case Type::VoidTyID:
+    return LLVMVoidTypeKind;
+  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::OpaqueTyID:
+    return LLVMOpaqueTypeKind;
+  case Type::VectorTyID:
+    return LLVMVectorTypeKind;
+  default:
+    assert (false && "Unhandled TypeID.");
+  }
 }
 
 /*--.. Operations on integer types .........................................--*/