@@ -14600,20 +14600,23 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
14600
14600
return Error(E);
14601
14601
const Expr *LHSExpr = LHSValue.Base.dyn_cast<const Expr *>();
14602
14602
const Expr *RHSExpr = RHSValue.Base.dyn_cast<const Expr *>();
14603
- if (!LHSExpr || !RHSExpr) {
14604
- std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14605
- std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14606
- Info.FFDiag(E, diag::note_constexpr_pointer_arith_unspecified)
14607
- << LHS << RHS;
14608
- return false;
14609
- }
14610
14603
14611
- if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue)) {
14612
- std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
14613
- std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
14614
- Info.FFDiag(E, diag::note_constexpr_literal_arith) << LHS << RHS;
14604
+ auto DiagArith = [&](unsigned DiagID) {
14605
+ std::string LHS = LHSValue.toString(Info.Ctx, LHSExpr->getType());
14606
+ std::string RHS = RHSValue.toString(Info.Ctx, RHSExpr->getType());
14607
+ Info.FFDiag(E, DiagID) << LHS << RHS;
14608
+ if (LHSExpr && LHSExpr == RHSExpr)
14609
+ Info.Note(LHSExpr->getExprLoc(),
14610
+ diag::note_constexpr_repeated_literal_eval)
14611
+ << LHSExpr->getSourceRange();
14615
14612
return false;
14616
- }
14613
+ };
14614
+
14615
+ if (!LHSExpr || !RHSExpr)
14616
+ return DiagArith(diag::note_constexpr_pointer_arith_unspecified);
14617
+
14618
+ if (ArePotentiallyOverlappingStringLiterals(Info, LHSValue, RHSValue))
14619
+ return DiagArith(diag::note_constexpr_literal_arith);
14617
14620
14618
14621
const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
14619
14622
const AddrLabelExpr *RHSAddrExpr = dyn_cast<AddrLabelExpr>(RHSExpr);
0 commit comments