@@ -14588,20 +14588,23 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
14588
14588
return Error(E);
14589
14589
const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr *>();
14590
14590
const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr *>();
14591
- if (!LHSExpr || !RHSExpr) {
14592
- std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14593
- std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14594
- Info.FFDiag(E, diag::note_constexpr_pointer_arith_unspecified)
14595
- << LHS << RHS;
14596
- return false;
14597
- }
14598
14591
14599
- if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue)) {
14600
- std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14601
- std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14602
- Info.FFDiag(E, diag::note_constexpr_literal_arith) << LHS << RHS;
14592
+ auto DiagArith = [&](unsigned DiagID) {
14593
+ std::string LHS = LHSValue.toString(Info.Ctx, LHSExpr->getType());
14594
+ std::string RHS = RHSValue.toString(Info.Ctx, RHSExpr->getType());
14595
+ Info.FFDiag(E, DiagID) << LHS << RHS;
14596
+ if (LHSExpr && LHSExpr == RHSExpr)
14597
+ Info.Note(LHSExpr->getExprLoc(),
14598
+ diag::note_constexpr_repeated_literal_eval)
14599
+ << LHSExpr->getSourceRange();
14603
14600
return false;
14604
- }
14601
+ };
14602
+
14603
+ if (!LHSExpr || !RHSExpr)
14604
+ return DiagArith(diag::note_constexpr_pointer_arith_unspecified);
14605
+
14606
+ if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue))
14607
+ return DiagArith(diag::note_constexpr_literal_arith);
14605
14608
14606
14609
const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
14607
14610
const AddrLabelExpr *RHSAddrExpr = dyn_cast<AddrLabelExpr>(RHSExpr);
0 commit comments