File tree 1 file changed +6
-8
lines changed
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -4699,12 +4699,9 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
4699
4699
if (LV.isSimple ()) {
4700
4700
Address V = LV.getAddress (*this );
4701
4701
if (V.isValid ()) {
4702
- llvm::Type *T =
4703
- ConvertTypeForMem (E->getType ())
4704
- ->getPointerTo (
4705
- cast<llvm::PointerType>(V.getType ())->getAddressSpace ());
4706
- if (V.getType () != T)
4707
- LV.setAddress (Builder.CreateBitCast (V, T));
4702
+ llvm::Type *T = ConvertTypeForMem (E->getType ());
4703
+ if (V.getElementType () != T)
4704
+ LV.setAddress (Builder.CreateElementBitCast (V, T));
4708
4705
}
4709
4706
}
4710
4707
return LV;
@@ -4763,8 +4760,9 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
4763
4760
4764
4761
CGM.EmitExplicitCastExprType (CE, this );
4765
4762
LValue LV = EmitLValue (E->getSubExpr ());
4766
- Address V = Builder.CreateBitCast (LV.getAddress (*this ),
4767
- ConvertType (CE->getTypeAsWritten ()));
4763
+ Address V = Builder.CreateElementBitCast (
4764
+ LV.getAddress (*this ),
4765
+ ConvertTypeForMem (CE->getTypeAsWritten ()->getPointeeType ()));
4768
4766
4769
4767
if (SanOpts.has (SanitizerKind::CFIUnrelatedCast))
4770
4768
EmitVTablePtrCheckForCast (E->getType (), V.getPointer (),
You can’t perform that action at this time.
0 commit comments