summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-15 22:00:31 +0000
committerChris Lattner <sabre@nondot.org>2009-07-15 22:00:31 +0000
commit0df5c8e3f1061cd23f8abde64840828f713d4597 (patch)
treece56f62e6754f950cf8047a79451f6f787f18726
parent23702eacab9d7fa21f250113d02e413a7ac50fda (diff)
downloadllvm-0df5c8e3f1061cd23f8abde64840828f713d4597.tar.gz
llvm-0df5c8e3f1061cd23f8abde64840828f713d4597.tar.bz2
llvm-0df5c8e3f1061cd23f8abde64840828f713d4597.tar.xz
Update the C bindings to keep the LLVMTypeKind up to date between the C/C++
stuff. Patch by Zoltan Varga! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75842 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm-c/Core.h3
-rw-r--r--include/llvm/Type.h1
-rw-r--r--lib/VMCore/Core.cpp35
3 files changed, 37 insertions, 2 deletions
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index a22d12ed86..d723d11111 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -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 {
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 38c4e30539..c311dbedc7 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -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
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index d04701e146..600bda6fa5 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -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 .........................................--*/