@@ -4318,14 +4318,14 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
4318
4318
// GEP indexes are signed, and scaling an index isn't permitted to
4319
4319
// signed-overflow, so we use the same semantics for our explicit
4320
4320
// multiply. We suppress this if overflow is not undefined behavior.
4321
- if (getLangOpts ().isSignedOverflowDefined () ) {
4321
+ if (getLangOpts ().PointerOverflowDefined ) {
4322
4322
Idx = Builder.CreateMul (Idx, numElements);
4323
4323
} else {
4324
4324
Idx = Builder.CreateNSWMul (Idx, numElements);
4325
4325
}
4326
4326
4327
4327
Addr = emitArraySubscriptGEP (*this , Addr, Idx, vla->getElementType (),
4328
- !getLangOpts ().isSignedOverflowDefined () ,
4328
+ !getLangOpts ().PointerOverflowDefined ,
4329
4329
SignedIndices, E->getExprLoc ());
4330
4330
4331
4331
} else if (const ObjCObjectType *OIT = E->getType ()->getAs <ObjCObjectType>()){
@@ -4415,7 +4415,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
4415
4415
QualType arrayType = Array->getType ();
4416
4416
Addr = emitArraySubscriptGEP (
4417
4417
*this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4418
- E->getType (), !getLangOpts ().isSignedOverflowDefined () , SignedIndices,
4418
+ E->getType (), !getLangOpts ().PointerOverflowDefined , SignedIndices,
4419
4419
E->getExprLoc (), &arrayType, E->getBase ());
4420
4420
EltBaseInfo = ArrayLV.getBaseInfo ();
4421
4421
EltTBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, E->getType ());
@@ -4424,10 +4424,9 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
4424
4424
Addr = EmitPointerWithAlignment (E->getBase (), &EltBaseInfo, &EltTBAAInfo);
4425
4425
auto *Idx = EmitIdxAfterBase (/* Promote*/ true );
4426
4426
QualType ptrType = E->getBase ()->getType ();
4427
- Addr = emitArraySubscriptGEP (*this , Addr, Idx, E->getType (),
4428
- !getLangOpts ().isSignedOverflowDefined (),
4429
- SignedIndices, E->getExprLoc (), &ptrType,
4430
- E->getBase ());
4427
+ Addr = emitArraySubscriptGEP (
4428
+ *this , Addr, Idx, E->getType (), !getLangOpts ().PointerOverflowDefined ,
4429
+ SignedIndices, E->getExprLoc (), &ptrType, E->getBase ());
4431
4430
}
4432
4431
4433
4432
LValue LV = MakeAddrLValue (Addr, E->getType (), EltBaseInfo, EltTBAAInfo);
@@ -4572,11 +4571,11 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
4572
4571
: llvm::ConstantInt::get (IntPtrTy, ConstLength);
4573
4572
Idx = Builder.CreateAdd (LowerBoundVal, LengthVal, " lb_add_len" ,
4574
4573
/* HasNUW=*/ false ,
4575
- !getLangOpts ().isSignedOverflowDefined () );
4574
+ !getLangOpts ().PointerOverflowDefined );
4576
4575
if (Length && LowerBound) {
4577
4576
Idx = Builder.CreateSub (
4578
4577
Idx, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " idx_sub_1" ,
4579
- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4578
+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
4580
4579
}
4581
4580
} else
4582
4581
Idx = llvm::ConstantInt::get (IntPtrTy, ConstLength + ConstLowerBound);
@@ -4602,7 +4601,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
4602
4601
Length->getType ()->hasSignedIntegerRepresentation ());
4603
4602
Idx = Builder.CreateSub (
4604
4603
LengthVal, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " len_sub_1" ,
4605
- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4604
+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
4606
4605
} else {
4607
4606
ConstLength = ConstLength.zextOrTrunc (PointerWidthInBits);
4608
4607
--ConstLength;
@@ -4629,12 +4628,12 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
4629
4628
// GEP indexes are signed, and scaling an index isn't permitted to
4630
4629
// signed-overflow, so we use the same semantics for our explicit
4631
4630
// multiply. We suppress this if overflow is not undefined behavior.
4632
- if (getLangOpts ().isSignedOverflowDefined () )
4631
+ if (getLangOpts ().PointerOverflowDefined )
4633
4632
Idx = Builder.CreateMul (Idx, NumElements);
4634
4633
else
4635
4634
Idx = Builder.CreateNSWMul (Idx, NumElements);
4636
4635
EltPtr = emitArraySubscriptGEP (*this , Base, Idx, VLA->getElementType (),
4637
- !getLangOpts ().isSignedOverflowDefined () ,
4636
+ !getLangOpts ().PointerOverflowDefined ,
4638
4637
/* signedIndices=*/ false , E->getExprLoc ());
4639
4638
} else if (const Expr *Array = isSimpleArrayDecayOperand (E->getBase ())) {
4640
4639
// If this is A[i] where A is an array, the frontend will have decayed the
@@ -4654,7 +4653,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
4654
4653
// Propagate the alignment from the array itself to the result.
4655
4654
EltPtr = emitArraySubscriptGEP (
4656
4655
*this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4657
- ResultExprTy, !getLangOpts ().isSignedOverflowDefined () ,
4656
+ ResultExprTy, !getLangOpts ().PointerOverflowDefined ,
4658
4657
/* signedIndices=*/ false , E->getExprLoc ());
4659
4658
BaseInfo = ArrayLV.getBaseInfo ();
4660
4659
TBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, ResultExprTy);
@@ -4663,7 +4662,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
4663
4662
emitOMPArraySectionBase (*this , E->getBase (), BaseInfo, TBAAInfo, BaseTy,
4664
4663
ResultExprTy, IsLowerBound);
4665
4664
EltPtr = emitArraySubscriptGEP (*this , Base, Idx, ResultExprTy,
4666
- !getLangOpts ().isSignedOverflowDefined () ,
4665
+ !getLangOpts ().PointerOverflowDefined ,
4667
4666
/* signedIndices=*/ false , E->getExprLoc ());
4668
4667
}
4669
4668
0 commit comments