Skip to content

DW_AT_artificial for structured bindings is incorrectly set #48909

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 49565
Version trunk
OS Linux
Attachments Test case
Reporter LLVM Bugzilla Contributor
CC @dwblaikie,@pogo59,@zygoloid

Extended Description

With structured bindings:

  auto [test_i, test_s] = GetTest();

Clang generates three variables in the DWARF symbols, one unnamed one for the std::pair returned from GetTest(), and then test_i and test_s. But test_i and test_s are marked as DW_AT_artifical even though they were user-declared, and the unnamed one is not, even though it was not user-declared:

0x000048c6:     DW_TAG_variable
                  DW_AT_location	(DW_OP_fbreg -40)
                  DW_AT_decl_file	("/home/brettw/eraseme3.cc")
                  DW_AT_decl_line	(13)
                  DW_AT_type	(0x00002b98 "pair<int, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>>")

0x000048d0:     DW_TAG_variable
                  DW_AT_location	(DW_OP_fbreg -48)
                  DW_AT_name	("test_i")
                  DW_AT_type	(0x0000484a "int&&")
                  DW_AT_artificial	(true)

0x000048dc:     DW_TAG_variable
                  DW_AT_location	(DW_OP_fbreg -56)
                  DW_AT_name	("test_s")
                  DW_AT_type	(0x000030db "basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>&&")
                  DW_AT_artificial	(true)

This is backwards. The unnamed pair should be marked "artificial" while the two named variables in the structured bindings should not.

GCC encodes the artificial tags in way I propose:

0x00005ed0:     DW_TAG_variable
                  DW_AT_type	(0x00003316 "pair<int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >")
                  DW_AT_artificial	(true)
                  DW_AT_location	(DW_OP_fbreg -96)

0x00005ed9:     DW_TAG_variable
                  DW_AT_name	("test_i")
                  DW_AT_decl_file	("/home/brettw/eraseme3.cc")
                  DW_AT_decl_line	(13)
                  DW_AT_decl_column	(0x09)
                  DW_AT_type	(0x00005ef8 "type&&")
                  DW_AT_location	(DW_OP_fbreg -40)

0x00005ee8:     DW_TAG_variable
                  DW_AT_name	("test_s")
                  DW_AT_decl_file	("/home/brettw/eraseme3.cc")
                  DW_AT_decl_line	(13)
                  DW_AT_decl_column	(0x11)
                  DW_AT_type	(0x00005efe "type&&")
                  DW_AT_location	(DW_OP_fbreg -48)

Fuchsia clang version 11.0.0 (https://fuchsia.googlesource.com/a/third_party/llvm-project 65f5887)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++17clang:codegenIR generation bugs: mangling, exceptions, etc.debuginfo

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions