[clang] [Clang] fix(95366): enhance cast operation safety with LValue validation (PR #95479)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 08:02:57 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 0a57a20aa506c5a5a8b0a8eb45446d0747493d7c 5347a0d44580167df364faf6b7a5dd60a52b9e88 -- clang/test/Sema/integral-to-ptr.c 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 2b7a056641..712c3062eb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9326,8 +9326,9 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return true;
     } else {
       // In rare instances, the value isn't an lvalue.
-      // For example, when the value is the difference between the addresses of two labels.
-      // We reject that as a constant expression because we can't compute a valid offset to convert into a pointer.
+      // For example, when the value is the difference between the addresses of
+      // two labels. We reject that as a constant expression because we can't
+      // compute a valid offset to convert into a pointer.
       if (!Value.isLValue())
         return false;
 

``````````

</details>


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


More information about the cfe-commits mailing list