Skip to content

Commit cba95f8

Browse files
committed
string: Fix deprecation of getElementType()
1 parent 3f2ea3e commit cba95f8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

string/StringObfuscation.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,15 @@ void StringObfuscatorPass::addDecodeAllStringsFunction(
209209
// at the field index
210210
if (str.isStruct) {
211211
array = builder.CreateStructGEP(
212-
str.var->getType()->getPointerElementType(), str.var, str.index);
212+
str.var->getValueType(), str.var, str.index);
213213
}
214214

215-
// Get a pointer to the first element of the array (start of the string)
215+
// Get a pointer to the first element of the array (start of the string).
216+
// Use the actual array type [size x i8] as the GEP element type, not the
217+
// pointer type returned by getType() (which is opaque ptr in LLVM >= 15).
218+
auto arrayType = ArrayType::get(Type::getInt8Ty(ctx), str.size);
216219
auto ptr = builder.CreateConstInBoundsGEP2_32(
217-
array->getType()->getPointerElementType(), array, 0, 0);
220+
arrayType, array, 0, 0);
218221

219222
// Get the size of the string
220223
auto size = ConstantInt::get(IntegerType::getInt32Ty(ctx), str.size);

0 commit comments

Comments
 (0)