================
@@ -4309,16 +4292,39 @@ static Value *emitPointerArithmetic(CodeGenFunction 
&CGF,
   // future proof.
   llvm::Type *elemTy;
   if (elementType->isVoidType() || elementType->isFunctionType())
-    elemTy = CGF.Int8Ty;
+    elemTy = Int8Ty;
   else
-    elemTy = CGF.ConvertTypeForMem(elementType);
+    elemTy = ConvertTypeForMem(elementType);
 
-  if (CGF.getLangOpts().PointerOverflowDefined)
-    return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
+  if (getLangOpts().PointerOverflowDefined)
+    return Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
+
+  return EmitCheckedInBoundsGEP(elemTy, pointer, index, isSigned, 
isSubtraction,
+                                BO->getExprLoc(), "add.ptr");
+}
+
+/// BO_Add/BO_Sub are handled by EmitPointerWithAlignment to preserve alignment
+/// information.
+/// This is a fallback path for BO_AddAssign/BO_SubAssign.
----------------
efriedma-quic wrote:

"fallback path" doesn't seem accurate, if it's the primary path for compound 
assignment; probably just say "This function is used for 
BO_AddAssign/BO_SubAssign."

We could do something with the result of BO_AddAssign/BO_SubAssign in C; it's 
just a plain pointer, like a normal add/sub, just with a side-effect of 
modifying the pointer.  Not sure how much that matters in practice.  (The 
result of BO_AddAssign is an lvalue in C++, though.)

https://github.com/llvm/llvm-project/pull/152575
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to