[clang] Allow packing fields into tail padding of record fields (PR #122197)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 8 16:08:55 PST 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 e93181bf13b289823810d3b43bcc3c2df1eda70b 54eaf769c085d8efeab957a5f385bca59a3f1f32 --extensions cpp -- clang/lib/CodeGen/CGExprConstant.cpp clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/test/CodeGenCXX/no-unique-address-3.cpp clang/test/CodeGenCXX/override-layout.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 00f21e393a..060385ca92 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -773,8 +773,7 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) {
     // When emitting a DesignatedInitUpdateExpr, a nested InitListExpr
     // represents additional overwriting of our current constant value, and not
     // a new constant to emit independently.
-    if (AllowOverwrite &&
-        (FieldTy->isArrayType() || FieldTy->isRecordType())) {
+    if (AllowOverwrite && (FieldTy->isArrayType() || FieldTy->isRecordType())) {
       if (auto *SubILE = dyn_cast<InitListExpr>(Init)) {
         CharUnits Offset = CGM.getContext().toCharUnitsFromBits(
             Layout.getFieldOffset(FieldNo));
@@ -810,7 +809,8 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) {
       // without checking for it, since it is not necessarily present in debug
       // info.
       if (const CXXRecordDecl *FieldRD = FieldTy->getAsCXXRecordDecl()) {
-        const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(FieldRD);
+        const ASTRecordLayout &Layout =
+            CGM.getContext().getASTRecordLayout(FieldRD);
         if (Layout.getDataSize() < Layout.getSize())
           AllowOverwrite = true;
       }

``````````

</details>


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


More information about the cfe-commits mailing list