git: cf24393421ca - main - Merge commit 69d42eef4bec from llvm-project (by Dimitry Andric):
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 22 Jun 2023 21:11:34 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=cf24393421ca807899c599a53ddc5dcedb7c71dc
commit cf24393421ca807899c599a53ddc5dcedb7c71dc
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-14 18:49:59 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-22 18:22:54 +0000
Merge commit 69d42eef4bec from llvm-project (by Dimitry Andric):
[Clang] Show type in enum out of range diagnostic
When the diagnostic for an out of range enum value is printed, it
currently does not show the actual enum type in question, for example:
v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]
static constexpr T kMax = static_cast<T>(kNumValues - 1);
^
This can make it cumbersome to find the cause for the problem. Add the
enum type to the diagnostic message, to make it easier.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D152788
PR: 271047
MFC after: 1 month
---
.../llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td | 4 ++--
contrib/llvm-project/clang/lib/AST/ExprConstant.cpp | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
index 28120d13fd9e..4e2e0bd3079c 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -393,8 +393,8 @@ def warn_fixedpoint_constant_overflow : Warning<
"overflow in expression; result is %0 with type %1">,
InGroup<DiagGroup<"fixed-point-overflow">>;
def warn_constexpr_unscoped_enum_out_of_range : Warning<
- "integer value %0 is outside the valid range of values [%1, %2] for this "
- "enumeration type">, DefaultError, InGroup<DiagGroup<"enum-constexpr-conversion">>;
+ "integer value %0 is outside the valid range of values [%1, %2] for the "
+ "enumeration type %3">, DefaultError, InGroup<DiagGroup<"enum-constexpr-conversion">>;
// This is a temporary diagnostic, and shall be removed once our
// implementation is complete, and like the preceding constexpr notes belongs
diff --git a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
index 464104139cb2..db6c07d4ab7f 100644
--- a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
@@ -13682,12 +13682,13 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
Info.Ctx.getDiagnostics().Report(
E->getExprLoc(), diag::warn_constexpr_unscoped_enum_out_of_range)
<< llvm::toString(Result.getInt(), 10) << Min.getSExtValue()
- << Max.getSExtValue();
+ << Max.getSExtValue() << ED;
else if (!ED->getNumNegativeBits() && ConstexprVar &&
Max.ult(Result.getInt().getZExtValue()))
- Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
- diag::warn_constexpr_unscoped_enum_out_of_range)
- << llvm::toString(Result.getInt(),10) << Min.getZExtValue() << Max.getZExtValue();
+ Info.Ctx.getDiagnostics().Report(
+ E->getExprLoc(), diag::warn_constexpr_unscoped_enum_out_of_range)
+ << llvm::toString(Result.getInt(), 10) << Min.getZExtValue()
+ << Max.getZExtValue() << ED;
}
}