> This is not a valid structured binding pack, it needs to be used in a
template.

Good catch, thanks for the correction!

> Are there other places where the type pack would show up, other than as a
template parameter? Might help inform the design a bit more.

Not that I’m aware of (in C++). Maybe other languages have additional uses
of “type packs”. Haven’t checked that. Though “type” may be not the
most accurate name since one might have non-type template parameters in
that list.

On Wed, Sep 17, 2025 at 17:26 David Blaikie via Dwarf-discuss <
[email protected]> wrote:

> Thanks for bringing this up/working on these features.
>
> I certainly do like the generalization to DW_TAG_{type,variable}_pack.
>
> Are there other places where the type pack would show up, other than as a
> template parameter? Might help inform the design a bit more.
>
> I can't think of one, but I'd probably still vote for the
> name/generalization so it matches better with variable_pack, and maybe has
> some future uses we can't see yet.
>
> On Wed, Sep 17, 2025 at 12:19 AM Michael Buch <[email protected]> wrote:
>
>> Hi all,
>>
>> I have been working on some LLDB/debug-info issues surrounding parameter
>> packs recently and stumbled upon following DWARFv6 proposal:
>> https://dwarfstd.org/issues/250516.1.html
>>
>> I'm in favour of standardising parameter pack support in DWARF, but
>> wanted to recommend a few changes to the above proposal to make sure we
>> accommodate various use-cases not yet covered by it.
>>
>> At the time of the proposal there were two kinds of packs
>> 1. template parameter packs
>> 2. function parameter packs
>>
>> Since then two more kinds of packs have been added to the language:
>> 3. lambda capture packs (C++20)
>> 4. structured binding packs (C++26)
>>
>> The proposal currently describes (1) as DW_TAG_template_parameter_pack
>> and (2) as DW_TAG_formal_parameter_pack
>>
>> However, it seems to me that neither of these are suitable to describe
>> (3) and (4).
>>
>> # Lambda Capture Packs
>>
>> Here is an example of such pack:
>> ```
>> template <typename ... Args> auto f(Args&& ... args){ return [... args =
>> std::forward<Args>(args)] { // use args }; }
>> ```
>>
>> Here, `args` is actually a collection of init-capture declarations. In
>> DWARF one might want to represent these as
>> `DW_TAG_member`s on the anonymous lambda structure. However, neither 
>> DW_TAG_formal_parameter_pack
>> nor DW_TAG_template_parameter_pack would allow such a representation.
>>
>> # Structured Binding Packs
>>
>> Here is an example of such pack:
>> ```
>>
>> struct C { int x = 1, y = 2, z = 3; };
>>
>> void foo() {
>>   auto [d, ...e] = C();
>> }
>>
>> ```
>>
>> Here, `e` is a collection of variable declarations. In DWARF one might
>> want to represent these as `DW_TAG_variable`s local to the function `foo`.
>> But, again, neither of the proposed new tags currently allows this.
>>
>> More discussion on that here:
>> https://github.com/llvm/llvm-project/issues/152282
>>
>> # Proposed changes to the proposal
>>
>> A more general representation for packs would be having the notion of a
>> "type pack" and a "variable pack". The "type pack" is a collection of
>> types, which is what DW_TAG_template_paramaeter_pack encodes. A
>> "variable pack" is a collection of variable declarations, which could be
>> function parameters (DW_TAG_formal_parameter) or variables introduced
>> with structured bindings (DW_TAG_variable) or even variables introduced
>> via lambda capture packs (DW_TAG_member on the fake lambda structure).
>>
>>
>> That way we could represent the DWARF forauto [a, ...e] like so:
>>
>> ```
>>
>> DW_TAG_variable
>>    DW_AT_name ("a")
>>
>> DW_TAG_variable_pack
>>   DW_AT_name ("e")
>>   DW_TAG_variable
>>     DW_AT_type
>>     DW_AT_name ("fake_var_1") << may or may not be needed. Debugger could 
>> synthesize this
>>   DW_TAG_variable
>>     DW_AT_type
>>     DW_AT_name ("fake_var_2") << may or may not be needed. Debugger could 
>> synthesize this
>>
>> ```
>>
>>
>> Let me know if you have any questions/concerns with these suggestions. Happy 
>> to discuss!
>>
>> --
> Dwarf-discuss mailing list
> [email protected]
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
-- 
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to