================ @@ -14548,8 +14548,21 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Error(E); const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr *>(); const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr *>(); - if (!LHSExpr || !RHSExpr) - return Error(E); + if (!LHSExpr || !RHSExpr) { + std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType()); + std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType()); + Info.FFDiag(E, diag::note_constexpr_pointer_arith_unspecified) + << LHS << RHS; + return false; + } + + if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue)) { + std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType()); + std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType()); + Info.FFDiag(E, diag::note_constexpr_literal_arith) << LHS << RHS; ---------------- zygoloid wrote:
Do you think it's worth factoring out a lambda to do this `toString` work that's shared between these two diagnostics? (I'd imagine we'd want the same thing for the other two calls to `Error(E)` for pointer subtractions.) https://github.com/llvm/llvm-project/pull/118475 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits