[PATCH] D156546: [Clang][WIP]Experimental implementation of packed data members declarations

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 28 14:35:13 PDT 2023


dblaikie added a comment.

(just a side note about the title of this patch: I got "packed data members" confused and thought this was referring to struct packing `__attribute__((packed))` - so perhaps something more like "data member packs" would be a more clear term here?)



================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3281-3282
+        // Generate a new field from PackExpansion field.
+        Decl *NewMember = Instantiator.Visit(Member);
+        if (NewMember) {
+          FieldDecl *PackedField = dyn_cast<FieldDecl>(NewMember);
----------------



================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3283
+        if (NewMember) {
+          FieldDecl *PackedField = dyn_cast<FieldDecl>(NewMember);
+          Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, Arg);
----------------



================
Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:8-12
+template<typename T, typename... Ts> struct S2 {
+    T t[2];
+    Ts... ts;
+};
+
----------------
Did this test case come out of any particular bug discovered during implementation?


================
Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:14
+// CHECK: %struct.S1 = type { i32 }
+S1<int> s1;
+// CHECK-NEXT: %struct.S1.0 = type { i32, float, double }
----------------
Not sure, but might be worth a test with multiple of the same type in the pack?


================
Comment at: clang/test/CodeGenCXX/packed_data_member.cpp:27
+S1<> s5;
\ No newline at end of file

----------------
(please add the missing newline at the end of the file here)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156546/new/

https://reviews.llvm.org/D156546



More information about the cfe-commits mailing list