[PATCH] D158006: [Clang][WIP]Experimental implementation of data member packs in dependent context.

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 13:29:29 PDT 2023


cjdb added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:3292
+          std::string NewFieldName =
+              PackedField->getName().str() + "@" + std::to_string(Arg);
+          PackedField->setDeclName(&Context.Idents.get(NewFieldName));
----------------
Does LLVM have some form of `absl::StrCat` that we can use instead of `operator+`?


================
Comment at: clang/lib/Sema/TreeTransform.h:4191-4218
+          // Transform unexpanded field name and create a new member expression.
+          DeclarationName ExpandedName = &SemaRef.Context.Idents.get(
+              UnExpanedNameStr + "@" + std::to_string(Arg));
+          // Construct name info with new name and keep other members the same.
+          DeclarationNameInfo ExpandedNameInfo = DeclarationNameInfo(
+              ExpandedName, MemberExpr->getMemberNameInfo().getLoc(),
+              MemberExpr->getMemberNameInfo().getInfo());
----------------
It may be worth putting this into its own named function to help with readability.


================
Comment at: clang/test/CodeGenCXX/data_member_packs.cpp:73
+  // CHECK: i32 @_Z3sumIJiiEEDaDpT_(i32 noundef %ts, i32 noundef %ts1)
+  sum_pack2<int, int>(s6);
+  // Check instantiation of sum(int, long, float, double)
----------------
This needs to be passed to one of the sum functions and checked that it's generating the correct code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158006



More information about the cfe-commits mailing list