[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-25 Thread Bill Wendling via cfe-commits
bwendling wrote: @tstellar PR https://github.com/llvm/llvm-project/pull/90118 is the fix here. https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
@@ -826,29 +826,32 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) { const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLe

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Eli Friedman via cfe-commits
@@ -826,29 +826,32 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) { const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLe

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/89126 >From 36ddb5811f11a1f6968705005713f34713026dbb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 17 Apr 2024 12:23:02 -0700 Subject: [PATCH 1/8] [Clang] Handle structs with inner structs and no fields A

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM Please don't forget to fix CountCountedByAttrs... but it's fine if it's in a followup. https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/89126 >From 36ddb5811f11a1f6968705005713f34713026dbb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 17 Apr 2024 12:23:02 -0700 Subject: [PATCH 1/8] [Clang] Handle structs with inner structs and no fields A

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,40 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + int x,y,z; + struct bar

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,40 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + int x,y,z; + struct bar

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/89126 >From 36ddb5811f11a1f6968705005713f34713026dbb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 17 Apr 2024 12:23:02 -0700 Subject: [PATCH 1/4] [Clang] Handle structs with inner structs and no fields A

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
bwendling wrote: > We should probably apply the same fix to CountCountedByAttrs. > > Along those lines, we should be able to handle: > > ``` > struct bar { > int count; > int array[] __attribute__((counted_by(count))); > }; > struct foo { struct bar x; }; > void init(void * __attribute__((p

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -826,29 +826,31 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) { const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLe

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: We should probably apply the same fix to CountCountedByAttrs. Along those lines, we should be able to handle: ``` struct bar { int count; int array[] __attribute__((counted_by(count))); }; struct foo { struct bar x; }; void init(void * __attribute

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/89126 >From 36ddb5811f11a1f6968705005713f34713026dbb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 17 Apr 2024 12:23:02 -0700 Subject: [PATCH 1/3] [Clang] Handle structs with inner structs and no fields A

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: > if there's an inner struct that's not accessible, that doesn't affect the > offsets of fields outside of that inner

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = bwendling wrote: I did several tests, and it looks like if there's an inner struct that's not accessible, that doesn't affect the offsets of

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Bill Wendling via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = bwendling wrote: > FieldNo and Layout are referring to fields of "RD"; the "Field" found in the > recursive visit is a member of Record (or

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: Maybe instead of looking for RecordDecls, this code should be looking for fields where the type of the field is an anon

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: FieldNo and Layout are referring to fields of "RD"; the "Field" found in the recursive visit is a member of Record (or

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Kees Cook via cfe-commits
https://github.com/kees approved this pull request. Tests and logic adjustment looks good to me. https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/89126 >From 36ddb5811f11a1f6968705005713f34713026dbb Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 17 Apr 2024 12:23:02 -0700 Subject: [PATCH 1/2] [Clang] Handle structs with inner structs and no fields A

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 1460b4964c7ada2f7536006722c8585b5bd0a1b5 36ddb5811f11a1f6968705005713f34713026dbb --

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Bill Wendling (bwendling) Changes A struct that declares an inner struct, but no fields, won't have a field count. So getting the offset of the inner struct fails. This happens in both C and C++: struct foo { struct bar { int

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/89126 A struct that declares an inner struct, but no fields, won't have a field count. So getting the offset of the inner struct fails. This happens in both C and C++: struct foo { struct bar { int Quan