[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 10:21:04 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 d4a0154902fb9b0611ed857134b26a64a1d5ad1e 3c944c05fded091f9488a9786bc80c57e291b6ed --extensions h,cpp -- clang/test/SemaCXX/constant-expression-p2280r4.cpp clang/include/clang/AST/APValue.h clang/lib/AST/APValue.cpp clang/lib/AST/ExprConstant.cpp clang/test/SemaCXX/constant-expression-cxx11.cpp clang/test/SemaCXX/constant-expression-cxx2a.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 a7e2cc455e..424df336f2 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13654,9 +13654,10 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
       return false;
 
     // If we have Unknown pointers we should fail if they are not global values.
-    if (!(IsGlobalLValue(LHSValue.getLValueBase()) && IsGlobalLValue(RHSValue.getLValueBase())) &&
-         (LHSValue.AllowConstexprUnknown || RHSValue.AllowConstexprUnknown))
-         return false;
+    if (!(IsGlobalLValue(LHSValue.getLValueBase()) &&
+          IsGlobalLValue(RHSValue.getLValueBase())) &&
+        (LHSValue.AllowConstexprUnknown || RHSValue.AllowConstexprUnknown))
+      return false;
 
     // Reject differing bases from the normal codepath; we special-case
     // comparisons to null.

``````````

</details>


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


More information about the cfe-commits mailing list