[lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 15 13:58:19 PST 2023


dyung wrote:

Hi @Michael137, we are seeing a failure in one of our internal tests that I bisected back to this change. Consider the following code:
```C++
struct X
{
    static const int constant = 1;
    int x;

    X() { x = constant; }
};
const int X::constant;

int main()
{
    X x;
    x.x = X::constant;
    x.x = X::constant;
    x.x = X::constant;
    x.x = X::constant;
    x.x = X::constant;
    return 0;
}
```
Prior to your change, the compiler would generate the following DWARF for the constant value:
```
0x0000003a:     DW_TAG_member
                  DW_AT_name    ("constant")
                  DW_AT_type    (0x00000057 "const int")
                  DW_AT_decl_file       ("/home/dyung/sandbox/test.cpp")
                  DW_AT_decl_line       (3)
                  DW_AT_external        (true)
                  DW_AT_declaration     (true)
                  DW_AT_const_value     (1)
```
After your change, the DW_AT_const_value is gone from this DW_TAG_member group, but doesn't appear anywhere else in the DWARF output which seems to indicate that it was dropped completely which does not seem to be correct. Is this intended or am I missing something?

https://github.com/llvm/llvm-project/pull/71780


More information about the cfe-commits mailing list