[C API] Add LLVMStructGetTypeAtIndex.
authorPeter Zotov <whitequark@whitequark.org>
Thu, 4 Jun 2015 09:09:53 +0000 (09:09 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Thu, 4 Jun 2015 09:09:53 +0000 (09:09 +0000)
Patch by deadalnix (Amaury SECHET).

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

include/llvm-c/Core.h
lib/IR/Core.cpp

index effbd15c10ddf8ac89bb4f14209982fe36d206ff..73bff0b7ec4903b88c902986b0d33b47d2cde99c 100644 (file)
@@ -997,6 +997,13 @@ unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
  */
 void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
 
+/**
+ * Get the type of the element at a given index in the structure.
+ *
+ * @see llvm::StructType::getTypeAtIndex()
+ */
+LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
+
 /**
  * Determine whether a structure is packed.
  *
index 9557cda5a9c87deef38762cb8aa3a2ed03dcb1dd..d476434542eaeef880e8f22f628837c3948558aa 100644 (file)
@@ -461,6 +461,11 @@ void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest) {
     *Dest++ = wrap(*I);
 }
 
+LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i) {
+  StructType *Ty = unwrap<StructType>(StructTy);
+  return wrap(Ty->getTypeAtIndex(i));
+}
+
 LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy) {
   return unwrap<StructType>(StructTy)->isPacked();
 }