From: Peter Zotov Date: Thu, 4 Jun 2015 09:09:53 +0000 (+0000) Subject: [C API] Add LLVMStructGetTypeAtIndex. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d34142ebf7bb4b9ced2ad950662d5b90678f1d0d;p=oota-llvm.git [C API] Add LLVMStructGetTypeAtIndex. Patch by deadalnix (Amaury SECHET). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239029 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(); }