diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index effbd15c10d..73bff0b7ec4 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -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. * diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 9557cda5a9c..d476434542e 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -461,6 +461,11 @@ void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest) { *Dest++ = wrap(*I); } +LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i) { + StructType *Ty = unwrap(StructTy); + return wrap(Ty->getTypeAtIndex(i)); +} + LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy) { return unwrap(StructTy)->isPacked(); }