[PATCH] D158006: [Clang][WIP]Experimental implementation of data member packs in dependent context.
Zenong Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 17 19:00:36 PDT 2023
SlaterLatiao added inline comments.
================
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)
----------------
cjdb wrote:
> This needs to be passed to one of the sum functions and checked that it's generating the correct code.
It's passed to `sum` and generation of `sum(int, int)` is checked.
================
Comment at: clang/test/CodeGenCXX/data_member_packs.cpp:76
+ // CHECK: double @_Z3sumIJilfdEEDaDpT_(i32 noundef %ts, i64 noundef %ts1, float noundef %ts3, double noundef %ts5)
+ S4<int, long>{}.sum_pack<float, double>(s7);
+ return 0;
----------------
denik wrote:
> This is a good test case!
> I would also add a test for the partial expansion of the member pack. And also checking the right order of the fields. Something like:
> ```
> template<typename T> constexpr auto foo(T t) { return t; }
> template<typename T, typename ... Ts> constexpr auto foo(T t, Ts ... ts) { return t + 2 * foo(ts...); }
>
> S1<int, int, int> s = {1,2,3};
> static_assert(foo(s.ts...) == 17);
> ```
>
We can't check the runtime state in LLVM/Clang tests. I added a test case for partial expansion and checked the IR. The order of fields can be checked by looking at the order of types in the instantiation of `sum`.
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