@@ -4311,14 +4311,14 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
43114311 // GEP indexes are signed, and scaling an index isn't permitted to
43124312 // signed-overflow, so we use the same semantics for our explicit
43134313 // multiply. We suppress this if overflow is not undefined behavior.
4314- if (getLangOpts ().isSignedOverflowDefined () ) {
4314+ if (getLangOpts ().PointerOverflowDefined ) {
43154315 Idx = Builder.CreateMul (Idx, numElements);
43164316 } else {
43174317 Idx = Builder.CreateNSWMul (Idx, numElements);
43184318 }
43194319
43204320 Addr = emitArraySubscriptGEP (*this , Addr, Idx, vla->getElementType (),
4321- !getLangOpts ().isSignedOverflowDefined () ,
4321+ !getLangOpts ().PointerOverflowDefined ,
43224322 SignedIndices, E->getExprLoc ());
43234323
43244324 } else if (const ObjCObjectType *OIT = E->getType ()->getAs <ObjCObjectType>()){
@@ -4408,7 +4408,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44084408 QualType arrayType = Array->getType ();
44094409 Addr = emitArraySubscriptGEP (
44104410 *this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4411- E->getType (), !getLangOpts ().isSignedOverflowDefined () , SignedIndices,
4411+ E->getType (), !getLangOpts ().PointerOverflowDefined , SignedIndices,
44124412 E->getExprLoc (), &arrayType, E->getBase ());
44134413 EltBaseInfo = ArrayLV.getBaseInfo ();
44144414 EltTBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, E->getType ());
@@ -4417,10 +4417,9 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
44174417 Addr = EmitPointerWithAlignment (E->getBase (), &EltBaseInfo, &EltTBAAInfo);
44184418 auto *Idx = EmitIdxAfterBase (/* Promote*/ true );
44194419 QualType ptrType = E->getBase ()->getType ();
4420- Addr = emitArraySubscriptGEP (*this , Addr, Idx, E->getType (),
4421- !getLangOpts ().isSignedOverflowDefined (),
4422- SignedIndices, E->getExprLoc (), &ptrType,
4423- E->getBase ());
4420+ Addr = emitArraySubscriptGEP (
4421+ *this , Addr, Idx, E->getType (), !getLangOpts ().PointerOverflowDefined ,
4422+ SignedIndices, E->getExprLoc (), &ptrType, E->getBase ());
44244423 }
44254424
44264425 LValue LV = MakeAddrLValue (Addr, E->getType (), EltBaseInfo, EltTBAAInfo);
@@ -4565,11 +4564,11 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
45654564 : llvm::ConstantInt::get (IntPtrTy, ConstLength);
45664565 Idx = Builder.CreateAdd (LowerBoundVal, LengthVal, " lb_add_len" ,
45674566 /* HasNUW=*/ false ,
4568- !getLangOpts ().isSignedOverflowDefined () );
4567+ !getLangOpts ().PointerOverflowDefined );
45694568 if (Length && LowerBound) {
45704569 Idx = Builder.CreateSub (
45714570 Idx, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " idx_sub_1" ,
4572- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4571+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
45734572 }
45744573 } else
45754574 Idx = llvm::ConstantInt::get (IntPtrTy, ConstLength + ConstLowerBound);
@@ -4595,7 +4594,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
45954594 Length->getType ()->hasSignedIntegerRepresentation ());
45964595 Idx = Builder.CreateSub (
45974596 LengthVal, llvm::ConstantInt::get (IntPtrTy, /* V=*/ 1 ), " len_sub_1" ,
4598- /* HasNUW=*/ false , !getLangOpts ().isSignedOverflowDefined () );
4597+ /* HasNUW=*/ false , !getLangOpts ().PointerOverflowDefined );
45994598 } else {
46004599 ConstLength = ConstLength.zextOrTrunc (PointerWidthInBits);
46014600 --ConstLength;
@@ -4622,12 +4621,12 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46224621 // GEP indexes are signed, and scaling an index isn't permitted to
46234622 // signed-overflow, so we use the same semantics for our explicit
46244623 // multiply. We suppress this if overflow is not undefined behavior.
4625- if (getLangOpts ().isSignedOverflowDefined () )
4624+ if (getLangOpts ().PointerOverflowDefined )
46264625 Idx = Builder.CreateMul (Idx, NumElements);
46274626 else
46284627 Idx = Builder.CreateNSWMul (Idx, NumElements);
46294628 EltPtr = emitArraySubscriptGEP (*this , Base, Idx, VLA->getElementType (),
4630- !getLangOpts ().isSignedOverflowDefined () ,
4629+ !getLangOpts ().PointerOverflowDefined ,
46314630 /* signedIndices=*/ false , E->getExprLoc ());
46324631 } else if (const Expr *Array = isSimpleArrayDecayOperand (E->getBase ())) {
46334632 // If this is A[i] where A is an array, the frontend will have decayed the
@@ -4647,7 +4646,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46474646 // Propagate the alignment from the array itself to the result.
46484647 EltPtr = emitArraySubscriptGEP (
46494648 *this , ArrayLV.getAddress (), {CGM.getSize (CharUnits::Zero ()), Idx},
4650- ResultExprTy, !getLangOpts ().isSignedOverflowDefined () ,
4649+ ResultExprTy, !getLangOpts ().PointerOverflowDefined ,
46514650 /* signedIndices=*/ false , E->getExprLoc ());
46524651 BaseInfo = ArrayLV.getBaseInfo ();
46534652 TBAAInfo = CGM.getTBAAInfoForSubobject (ArrayLV, ResultExprTy);
@@ -4656,7 +4655,7 @@ LValue CodeGenFunction::EmitArraySectionExpr(const ArraySectionExpr *E,
46564655 emitOMPArraySectionBase (*this , E->getBase (), BaseInfo, TBAAInfo, BaseTy,
46574656 ResultExprTy, IsLowerBound);
46584657 EltPtr = emitArraySubscriptGEP (*this , Base, Idx, ResultExprTy,
4659- !getLangOpts ().isSignedOverflowDefined () ,
4658+ !getLangOpts ().PointerOverflowDefined ,
46604659 /* signedIndices=*/ false , E->getExprLoc ());
46614660 }
46624661
0 commit comments