[clang] [Clang] Do not perform integral promotion if operands of expression `x ? : y` have the same type (PR #108837)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 07:47:10 PDT 2024


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 ed4a2a108ec867188c65f4c3743008db8dd1c0bb 7e5f88c322852939ae68c65f6adf4a5d2973d095 --extensions cpp -- clang/test/SemaCXX/conditional-gnu-ext.cpp clang/lib/Sema/SemaExpr.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 8414a55e48..c232d40ca3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8786,11 +8786,10 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
     }
     // We usually want to apply unary conversions *before* saving, except
     // in the special case in C++ that operands have the same type.
-    if (!(getLangOpts().CPlusPlus
-          && !commonExpr->isTypeDependent()
-          && commonExpr->isOrdinaryOrBitFieldObject()
-          && RHSExpr->isOrdinaryOrBitFieldObject()
-          && Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
+    if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() &&
+          commonExpr->isOrdinaryOrBitFieldObject() &&
+          RHSExpr->isOrdinaryOrBitFieldObject() &&
+          Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
       ExprResult commonRes = UsualUnaryConversions(commonExpr);
       if (commonRes.isInvalid())
         return ExprError();

``````````

</details>


https://github.com/llvm/llvm-project/pull/108837


More information about the cfe-commits mailing list