[clang] [Clang] Add diagnostic when scoped enumeration requires an explicit conversion for binary operations (PR #152698)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 15 04:04:33 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaExpr.cpp clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3.cpp clang/test/SemaCXX/enum-scoped.cpp clang/test/SemaCXX/opaque-enum-declaration-in-class-template.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ff89a5906..0a9fe1e68 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10773,10 +10773,10 @@ static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc,
unsigned diagID =
isCxx23 ? diag::note_no_implicit_conversion_for_scoped_enum_cxx23
: diag::note_no_implicit_conversion_for_scoped_enum;
- auto diagnosticHelper = [&S, isCxx23, diagID](const Expr *expr, const QualType type) {
+ auto diagnosticHelper = [&S, isCxx23, diagID](const Expr *expr,
+ const QualType type) {
SourceLocation beginLoc = expr->getBeginLoc();
- QualType intType =
- type->castAs<EnumType>()->getDecl()->getIntegerType();
+ QualType intType = type->castAs<EnumType>()->getDecl()->getIntegerType();
std::string insertionString =
isCxx23 ? "std::to_underlying("
: "static_cast<" + intType.getAsString() + ">(";
@@ -10793,7 +10793,8 @@ static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc,
}
QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
- SourceLocation Loc, BinaryOperatorKind Opc) {
+ SourceLocation Loc,
+ BinaryOperatorKind Opc) {
bool IsCompAssign = Opc == BO_MulAssign || Opc == BO_DivAssign;
bool IsDiv = Opc == BO_Div || Opc == BO_DivAssign;
``````````
</details>
https://github.com/llvm/llvm-project/pull/152698
More information about the cfe-commits
mailing list