[clang] [CIR] Let a record type mark what each member holds (PR #215174)

Adam Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 13:21:05 PDT 2026


================
@@ -621,6 +621,37 @@ def CIR_VoidType : CIR_Type<"Void", "void"> {
   }];
 }
 
+//===----------------------------------------------------------------------===//
+// RecordMemberKind
+//
+// What a record member holds, for members that do not hold source data.
+//===----------------------------------------------------------------------===//
+
+def CIR_RecordMemberKind : CIR_I32EnumAttr<
+    "RecordMemberKind", "what a record member holds", [
+  I32EnumAttrCase<"Data", 0, "data">,
+  I32EnumAttrCase<"Pad", 1, "pad">,
+  I32EnumAttrCase<"Empty", 2, "empty">
----------------
adams381 wrote:

I think Erich has the core of it, but picked a poor example.

```c++
struct S { char : 3; unsigned long long l; };
```

emits

```
{empty !u8i, !u64i}
```

However, this example shows what he means:

```c++
struct C { int a : 3; int : 0; int : 3; };
```

emits

```
{!u8i, pad !cir.array<!u8i x 3>, empty !u8i, pad !cir.array<!u8i x 3>}
```

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


More information about the cfe-commits mailing list