llvm.org GIT mirror llvm / fdae897
Add echo test for constant data arrays in the LLVM C API git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263350 91177308-0d34-0410-b5e6-96231b3b80d8 Amaury Sechet 4 years ago
2 changed file(s) with 12 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1010 @ext = external global i32*
1111 @cst = constant %S { i64 1, %S* @cst }
1212 @tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
13 @arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
14 @str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
1315 @hidden = hidden global i32 7
1416 @protected = protected global i32 23
1517 @section = global i32 27, section ".custom"
258258 return LLVMConstArray(LLVMGetElementType(Ty), Elts.data(), EltCount);
259259 }
260260
261 // Try contant data array
262 if (LLVMIsAConstantDataArray(Cst)) {
263 LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
264 unsigned EltCount = LLVMGetArrayLength(Ty);
265 SmallVector Elts;
266 for (unsigned i = 0; i < EltCount; i++)
267 Elts.push_back(clone_constant(LLVMGetElementAsConstant(Cst, i), M));
268 return LLVMConstArray(LLVMGetElementType(Ty), Elts.data(), EltCount);
269 }
270
261271 // Try constant struct
262272 if (LLVMIsAConstantStruct(Cst)) {
263273 LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);