[clang] [Clang][counted_by] Support casting the array to a different type (PR #136239)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 19:07:57 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,c -- clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/attr-counted-by.c
``````````

</details>

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

``````````diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 47aea8281..585e88d24 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1247,8 +1247,8 @@ CodeGenFunction::emitCountedByMemberSize(const Expr *E, llvm::Value *EmittedE,
       }
 
       //  field_offset += index * casted_field_base_size;
-      Value *Mul = Builder.CreateMul(Index, CastedArrayElementSize, "field_offset",
-                                     !IsSigned, IsSigned);
+      Value *Mul = Builder.CreateMul(Index, CastedArrayElementSize,
+                                     "field_offset", !IsSigned, IsSigned);
       FieldOffset = Builder.CreateAdd(FieldOffset, Mul);
     }
     // Option (3) '&ptr->field', and Option (4) continuation.

``````````

</details>


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


More information about the cfe-commits mailing list