[clang] [clang] Allow builtin addc/subc to be constant evaluated (PR #81656)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 11:58:43 PST 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 79fec2f8ba8ea0b0b1c2f13fb6355cb395e1d3af a49372838fdbd4c908cddcbe0144ffaf0a83991d -- clang/lib/AST/ExprConstant.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b518baec07..7da475d8eb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12720,24 +12720,26 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     case Builtin::BI__builtin_addc:
     case Builtin::BI__builtin_addcl:
     case Builtin::BI__builtin_addcll:
-      Result = LHS.uadd_ov(RHS, FirstOverflowed).uadd_ov(CarryIn, SecondOverflowed);
+      Result =
+          LHS.uadd_ov(RHS, FirstOverflowed).uadd_ov(CarryIn, SecondOverflowed);
       break;
     case Builtin::BI__builtin_subcb:
     case Builtin::BI__builtin_subcs:
     case Builtin::BI__builtin_subc:
     case Builtin::BI__builtin_subcl:
     case Builtin::BI__builtin_subcll:
-      Result = LHS.usub_ov(RHS, FirstOverflowed).usub_ov(CarryIn, SecondOverflowed);
+      Result =
+          LHS.usub_ov(RHS, FirstOverflowed).usub_ov(CarryIn, SecondOverflowed);
       break;
     }
 
-    // It is possible for both overflows to happen but CGBuiltin uses an OR so this is consistent
+    // It is possible for both overflows to happen but CGBuiltin uses an OR so
+    // this is consistent
     APSInt API{FirstOverflowed | SecondOverflowed};
     APValue APV{API};
     if (!handleAssignment(Info, E, CarryOutLValue, ResultType, APV))
       return false;
     return Success(Result, E);
-
   }
   case Builtin::BI__builtin_add_overflow:
   case Builtin::BI__builtin_sub_overflow:

``````````

</details>


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


More information about the cfe-commits mailing list