Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -2798,7 +2798,7 @@ if (Info.checkingForUndefinedBehavior()) Info.Ctx.getDiagnostics().Report(E->getExprLoc(), diag::warn_integer_constant_overflow) - << toString(Result, 10) << E->getType(); + << toString(Result, 10) << E->getType() << E->getSourceRange(); return HandleOverflow(Info, E, Value, E->getType()); } return true; @@ -13625,7 +13625,7 @@ if (Info.checkingForUndefinedBehavior()) Info.Ctx.getDiagnostics().Report(E->getExprLoc(), diag::warn_integer_constant_overflow) - << toString(Value, 10) << E->getType(); + << toString(Value, 10) << E->getType() << E->getSourceRange(); if (!HandleOverflow(Info, E, -Value.extend(Value.getBitWidth() + 1), E->getType())) Index: clang/lib/AST/Interp/Interp.h =================================================================== --- clang/lib/AST/Interp/Interp.h +++ clang/lib/AST/Interp/Interp.h @@ -269,7 +269,8 @@ SmallString<32> Trunc; Value.trunc(Result.bitWidth()).toString(Trunc, 10); auto Loc = E->getExprLoc(); - S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type; + S.report(Loc, diag::warn_integer_constant_overflow) + << Trunc << Type << E->getSourceRange(); return true; } else { S.CCEDiag(E, diag::note_constexpr_overflow) << Value << Type; @@ -476,7 +477,8 @@ SmallString<32> Trunc; NegatedValue.trunc(Result.bitWidth()).toString(Trunc, 10); auto Loc = E->getExprLoc(); - S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type; + S.report(Loc, diag::warn_integer_constant_overflow) + << Trunc << Type << E->getSourceRange(); return true; } @@ -529,7 +531,8 @@ SmallString<32> Trunc; APResult.trunc(Result.bitWidth()).toString(Trunc, 10); auto Loc = E->getExprLoc(); - S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type; + S.report(Loc, diag::warn_integer_constant_overflow) + << Trunc << Type << E->getSourceRange(); return true; } Index: clang/test/Misc/constexpr-source-ranges.cpp =================================================================== --- clang/test/Misc/constexpr-source-ranges.cpp +++ clang/test/Misc/constexpr-source-ranges.cpp @@ -13,3 +13,10 @@ constexpr const int *P = &I; constexpr long L = (long)P; // CHECK: constexpr-source-ranges.cpp:14:20:{14:20-14:27} + +namespace overflow { +// CHECK: :{[[@LINE+1]]:9-[[@LINE+1]]:29}: warning: overflow +int x = -1 + __INT_MAX__ + 2 + 3; +// CHECK: :{[[@LINE+1]]:9-[[@LINE+1]]:19}: warning: overflow +int a = -(1 << 31) + 1; +}