[llvm-bugs] [Bug 49565] New: DW_AT_artificial for structured bindings is incorrectly set

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 12 13:57:11 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49565

            Bug ID: 49565
           Summary: DW_AT_artificial for structured bindings is
                    incorrectly set
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: brettw at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 24634
  --> https://bugs.llvm.org/attachment.cgi?id=24634&action=edit
Test case

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
65f58878e72a40d68ef3899c766846ee9ec7cf29)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210312/ae4e060b/attachment.html>


More information about the llvm-bugs mailing list