@@ -1691,8 +1691,7 @@ LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
1691
1691
ArrayRef<Constant *> IdxList (unwrap<Constant>(ConstantIndices, NumIndices),
1692
1692
NumIndices);
1693
1693
Constant *Val = unwrap<Constant>(ConstantVal);
1694
- Type *Ty =
1695
- cast<PointerType>(Val->getType ()->getScalarType ())->getElementType ();
1694
+ Type *Ty = Val->getType ()->getScalarType ()->getNonOpaquePointerElementType ();
1696
1695
return wrap (ConstantExpr::getGetElementPtr (Ty, Val, IdxList));
1697
1696
}
1698
1697
@@ -1710,8 +1709,7 @@ LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
1710
1709
ArrayRef<Constant *> IdxList (unwrap<Constant>(ConstantIndices, NumIndices),
1711
1710
NumIndices);
1712
1711
Constant *Val = unwrap<Constant>(ConstantVal);
1713
- Type *Ty =
1714
- cast<PointerType>(Val->getType ()->getScalarType ())->getElementType ();
1712
+ Type *Ty = Val->getType ()->getScalarType ()->getNonOpaquePointerElementType ();
1715
1713
return wrap (ConstantExpr::getInBoundsGetElementPtr (Ty, Val, IdxList));
1716
1714
}
1717
1715
@@ -2278,7 +2276,8 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit) {
2278
2276
LLVMValueRef LLVMAddAlias (LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
2279
2277
const char *Name) {
2280
2278
auto *PTy = cast<PointerType>(unwrap (Ty));
2281
- return wrap (GlobalAlias::create (PTy->getElementType (), PTy->getAddressSpace (),
2279
+ return wrap (GlobalAlias::create (PTy->getNonOpaquePointerElementType (),
2280
+ PTy->getAddressSpace (),
2282
2281
GlobalValue::ExternalLinkage, Name,
2283
2282
unwrap<Constant>(Aliasee), unwrap (M)));
2284
2283
}
@@ -3218,7 +3217,7 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef B, LLVMValueRef Fn,
3218
3217
const char *Name) {
3219
3218
Value *V = unwrap (Fn);
3220
3219
FunctionType *FnT =
3221
- cast<FunctionType>(cast<PointerType>( V->getType ())-> getElementType ());
3220
+ cast<FunctionType>(V->getType ()-> getNonOpaquePointerElementType ());
3222
3221
3223
3222
return wrap (
3224
3223
unwrap (B)->CreateInvoke (FnT, unwrap (Fn), unwrap (Then), unwrap (Catch),
@@ -3590,7 +3589,8 @@ LLVMValueRef LLVMBuildLoad(LLVMBuilderRef B, LLVMValueRef PointerVal,
3590
3589
Value *V = unwrap (PointerVal);
3591
3590
PointerType *Ty = cast<PointerType>(V->getType ());
3592
3591
3593
- return wrap (unwrap (B)->CreateLoad (Ty->getElementType (), V, Name));
3592
+ return wrap (
3593
+ unwrap (B)->CreateLoad (Ty->getNonOpaquePointerElementType (), V, Name));
3594
3594
}
3595
3595
3596
3596
LLVMValueRef LLVMBuildLoad2 (LLVMBuilderRef B, LLVMTypeRef Ty,
@@ -3692,8 +3692,7 @@ LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3692
3692
const char *Name) {
3693
3693
ArrayRef<Value *> IdxList (unwrap (Indices), NumIndices);
3694
3694
Value *Val = unwrap (Pointer);
3695
- Type *Ty =
3696
- cast<PointerType>(Val->getType ()->getScalarType ())->getElementType ();
3695
+ Type *Ty = Val->getType ()->getScalarType ()->getNonOpaquePointerElementType ();
3697
3696
return wrap (unwrap (B)->CreateGEP (Ty, Val, IdxList, Name));
3698
3697
}
3699
3698
@@ -3709,8 +3708,7 @@ LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
3709
3708
const char *Name) {
3710
3709
ArrayRef<Value *> IdxList (unwrap (Indices), NumIndices);
3711
3710
Value *Val = unwrap (Pointer);
3712
- Type *Ty =
3713
- cast<PointerType>(Val->getType ()->getScalarType ())->getElementType ();
3711
+ Type *Ty = Val->getType ()->getScalarType ()->getNonOpaquePointerElementType ();
3714
3712
return wrap (unwrap (B)->CreateInBoundsGEP (Ty, Val, IdxList, Name));
3715
3713
}
3716
3714
@@ -3725,8 +3723,7 @@ LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
3725
3723
LLVMValueRef LLVMBuildStructGEP (LLVMBuilderRef B, LLVMValueRef Pointer,
3726
3724
unsigned Idx, const char *Name) {
3727
3725
Value *Val = unwrap (Pointer);
3728
- Type *Ty =
3729
- cast<PointerType>(Val->getType ()->getScalarType ())->getElementType ();
3726
+ Type *Ty = Val->getType ()->getScalarType ()->getNonOpaquePointerElementType ();
3730
3727
return wrap (unwrap (B)->CreateStructGEP (Ty, Val, Idx, Name));
3731
3728
}
3732
3729
@@ -3947,7 +3944,7 @@ LLVMValueRef LLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn,
3947
3944
const char *Name) {
3948
3945
Value *V = unwrap (Fn);
3949
3946
FunctionType *FnT =
3950
- cast<FunctionType>(cast<PointerType>( V->getType ())-> getElementType ());
3947
+ cast<FunctionType>(V->getType ()-> getNonOpaquePointerElementType ());
3951
3948
3952
3949
return wrap (unwrap (B)->CreateCall (FnT, unwrap (Fn),
3953
3950
makeArrayRef (unwrap (Args), NumArgs), Name));
0 commit comments