================
@@ -4169,11 +4169,16 @@ static Value *emitPointerArithmetic(CodeGenFunction 
&CGF,
   //   The index is not pointer-sized.
   //   The pointer type is not byte-sized.
   //
-  if (BinaryOperator::isNullPointerArithmeticExtension(CGF.getContext(),
-                                                       op.Opcode,
-                                                       expr->getLHS(),
-                                                       expr->getRHS()))
-    return CGF.Builder.CreateIntToPtr(index, pointer->getType());
+  // Note that we do not suppress the pointer overflow check in this case.
+  if (!CGF.SanOpts.has(SanitizerKind::PointerOverflow) &&
+      BinaryOperator::isNullPointerArithmeticExtension(
+          CGF.getContext(), op.Opcode, expr->getLHS(), expr->getRHS())) {
+    // isUnderlyingBasePointerConstantNull returns true does not indicate that
+    // the base pointer is null.
----------------
dtcxzyw wrote:

> We may not need `isUnderlyingBasePointerConstantNull`. We can just handle 
> `ConditionalOperator` in `Expr::isNullPointerConstant`.

It breaks `clang/test/Sema/conditional-expr.c`, so I decided to move the 
workaround into `isNullPointerArithmeticExtension`: 
https://github.com/llvm/llvm-project/pull/137851/commits/419863eb5169044d3c9f8350fdb3b172365f1b73

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

Reply via email to