[clang] [Clang][counted_by] Add support for 'counted_by' on struct pointers (PR #127116)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 13 11:45:44 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 72f4e656b8feb3665bd074fadf1db1e72b385030 b5b9b158e7e379f2d430584e3ccf519677bf27a3 --extensions c,h,cpp -- clang/test/CodeGen/attr-counted-by-for-pointers.c clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CodeGenFunction.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 876eb06772..d2a90c0ddf 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4273,7 +4273,8 @@ void CodeGenFunction::EmitCountedByBoundsChecking(
if (!CountFD)
return;
- if (std::optional<int64_t> Diff = getOffsetDifferenceInBits(*this, CountFD, FD)) {
+ if (std::optional<int64_t> Diff =
+ getOffsetDifferenceInBits(*this, CountFD, FD)) {
// FIXME: The 'static_cast' is necessary, otherwise the result turns into a
// uint64_t, which messes things up if we have a negative offset difference.
Diff = *Diff / static_cast<int64_t>(CGM.getContext().getCharWidth());
@@ -4283,9 +4284,9 @@ void CodeGenFunction::EmitCountedByBoundsChecking(
Addr = Builder.CreatePointerBitCastOrAddrSpaceCast(Addr, Int8PtrTy, Int8Ty);
llvm::Type *CountTy = ConvertType(CountFD->getType());
- llvm::Value *Res = Builder.CreateInBoundsGEP(
- Int8Ty, Addr.emitRawPointer(*this),
- Builder.getInt32(*Diff), ".counted_by.gep");
+ llvm::Value *Res =
+ Builder.CreateInBoundsGEP(Int8Ty, Addr.emitRawPointer(*this),
+ Builder.getInt32(*Diff), ".counted_by.gep");
Res = Builder.CreateAlignedLoad(CountTy, Res, getIntAlign(),
".counted_by.load");
``````````
</details>
https://github.com/llvm/llvm-project/pull/127116
More information about the cfe-commits
mailing list