[clang] [Clang][counted_by] Use the expr's RecordDecl if available (PR #205903)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 5 20:56:23 PDT 2026


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 origin/main HEAD --extensions c,cpp -- clang/test/CodeGen/attr-counted-by-nested-structs.c clang/lib/CodeGen/CGExpr.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</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 e53b4be55..57cab39c1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1064,8 +1064,7 @@ namespace {
 /// or through a chain of nested record fields (including anonymous
 /// structs/unions). This mirrors the GEP path that getGEPIndicesToField builds,
 /// and is used to identify the right anchor expression in Base.
-static bool recordContainsField(const RecordDecl *RD,
-                                const FieldDecl *Field) {
+static bool recordContainsField(const RecordDecl *RD, const FieldDecl *Field) {
   for (const FieldDecl *FD : RD->fields()) {
     if (FD == Field)
       return true;

``````````

</details>


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


More information about the cfe-commits mailing list