@@ -4318,14 +4318,14 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
43184318 // GEP indexes are signed, and scaling an index isn't permitted to
43194319 // signed-overflow, so we use the same semantics for our explicit
43204320 // multiply. We suppress this if overflow is not undefined behavior.
4321- if (getLangOpts ().isSignedOverflowDefined () ) {
4321+ if (getLangOpts ().PointerOverflowDefined ) {
43224322 Idx = Builder.CreateMul (Idx, numElements);
43234323 } else {
43244324 Idx = Builder.CreateNSWMul (Idx, numElements);
43254325 }
43264326
43274327 Addr = emitArraySubscriptGEP (*this , Addr, Idx, vla->getElementType (),
4328- !getLangOpts ().isSignedOverflowDefined () ,
4328+ !getLangOpts ().PointerOverflowDefined ,
43294329 SignedIndices, E->getExprLoc ());
43304330
43314331 } else if (const ObjCObjectType *OIT = E->getType ()->getAs <ObjCObjectType>()){
@@ -4415,7 +4415,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44154415 QualType arrayType = Array->getType ();
44164416 Addr = emitArraySubscriptGEP (
44174417 *this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4418- E->getType (), !getLangOpts ().isSignedOverflowDefined () , SignedIndices,
4418+ E->getType (), !getLangOpts ().PointerOverflowDefined , SignedIndices,
44194419 E->getExprLoc (), &arrayType, E->getBase ());
44204420 EltBaseInfo = ArrayLV.getBaseInfo ();
44214421 EltTBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, E->getType ());
@@ -4424,10 +4424,9 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44244424 Addr = EmitPointerWithAlignment (E->getBase (), &EltBaseInfo, &EltTBAAInfo);
44254425 auto *Idx = EmitIdxAfterBase (/* Promote*/ true );
44264426 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 ());
44314430 }
44324431
44334432 LValue LV = MakeAddrLValue (Addr, E->getType (), EltBaseInfo, EltTBAAInfo);
@@ -4572,11 +4571,11 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
45724571 : llvm::ConstantInt::get (IntPtrTy, ConstLength);
45734572 Idx = Builder.CreateAdd (LowerBoundVal, LengthVal, " lb_add_len" ,
45744573 /* HasNUW=*/ false ,
4575- !getLangOpts ().isSignedOverflowDefined () );
4574+ !getLangOpts ().PointerOverflowDefined );
45764575 if (Length && LowerBound) {
45774576 Idx = Builder.CreateSub (
45784577 Idx, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " idx_sub_1" ,
4579- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4578+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
45804579 }
45814580 } else
45824581 Idx = llvm::ConstantInt::get (IntPtrTy, ConstLength + ConstLowerBound);
@@ -4602,7 +4601,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46024601 Length->getType ()->hasSignedIntegerRepresentation ());
46034602 Idx = Builder.CreateSub (
46044603 LengthVal, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " len_sub_1" ,
4605- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4604+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
46064605 } else {
46074606 ConstLength = ConstLength.zextOrTrunc (PointerWidthInBits);
46084607 --ConstLength;
@@ -4629,12 +4628,12 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46294628 // GEP indexes are signed, and scaling an index isn't permitted to
46304629 // signed-overflow, so we use the same semantics for our explicit
46314630 // multiply. We suppress this if overflow is not undefined behavior.
4632- if (getLangOpts ().isSignedOverflowDefined () )
4631+ if (getLangOpts ().PointerOverflowDefined )
46334632 Idx = Builder.CreateMul (Idx, NumElements);
46344633 else
46354634 Idx = Builder.CreateNSWMul (Idx, NumElements);
46364635 EltPtr = emitArraySubscriptGEP (*this , Base, Idx, VLA->getElementType (),
4637- !getLangOpts ().isSignedOverflowDefined () ,
4636+ !getLangOpts ().PointerOverflowDefined ,
46384637 /* signedIndices=*/ false , E->getExprLoc ());
46394638 } else if (const Expr *Array = isSimpleArrayDecayOperand (E->getBase ())) {
46404639 // 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,
46544653 // Propagate the alignment from the array itself to the result.
46554654 EltPtr = emitArraySubscriptGEP (
46564655 *this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4657- ResultExprTy, !getLangOpts ().isSignedOverflowDefined () ,
4656+ ResultExprTy, !getLangOpts ().PointerOverflowDefined ,
46584657 /* signedIndices=*/ false , E->getExprLoc ());
46594658 BaseInfo = ArrayLV.getBaseInfo ();
46604659 TBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, ResultExprTy);
@@ -4663,7 +4662,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46634662 emitOMPArraySectionBase (*this , E->getBase (), BaseInfo, TBAAInfo, BaseTy,
46644663 ResultExprTy, IsLowerBound);
46654664 EltPtr = emitArraySubscriptGEP (*this , Base, Idx, ResultExprTy,
4666- !getLangOpts ().isSignedOverflowDefined () ,
4665+ !getLangOpts ().PointerOverflowDefined ,
46674666 /* signedIndices=*/ false , E->getExprLoc ());
46684667 }
46694668
0 commit comments