[clang] [NFC][Clang] Refactor code to calculate flexible array member size (PR #72790)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 19 02:33:43 PST 2023


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 42204c94ba9fcb0b4b1335e648ce140a3eef8a9d fcea607665cdbae3e98f08288b165c2c1af24f95 -- clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CodeGenFunction.h
``````````

</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 b869bca7f0..570675b590 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -948,10 +948,10 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
         ConstantInt::get(ResType, Layout.getSize().getQuantity(), IsSigned);
 
     Res = IsSigned
-              ? Builder.CreateBinaryIntrinsic(
-                    llvm::Intrinsic::smax, OffsetAndFAMSize, SizeofStruct)
-              : Builder.CreateBinaryIntrinsic(
-                    llvm::Intrinsic::umax, OffsetAndFAMSize, SizeofStruct);
+              ? Builder.CreateBinaryIntrinsic(llvm::Intrinsic::smax,
+                                              OffsetAndFAMSize, SizeofStruct)
+              : Builder.CreateBinaryIntrinsic(llvm::Intrinsic::umax,
+                                              OffsetAndFAMSize, SizeofStruct);
   } else if (const auto *ME = dyn_cast<MemberExpr>(Base)) {
     // Pointing to a place before the FAM. Add the difference to the FAM's
     // size.
@@ -969,9 +969,9 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
   // A negative 'FAMSize' means that the index was greater than the count,
   // or an improperly set count field. Return -1 (for types 0 and 1) or 0
   // (for types 2 and 3).
-  return Builder.CreateSelect(
-      Builder.CreateIsNeg(FAMSize),
-      getDefaultBuiltinObjectSizeResult(Type, ResType), Res);
+  return Builder.CreateSelect(Builder.CreateIsNeg(FAMSize),
+                              getDefaultBuiltinObjectSizeResult(Type, ResType),
+                              Res);
 }
 
 /// Returns a Value corresponding to the size of the given expression.

``````````

</details>


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


More information about the cfe-commits mailing list