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

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 11:17:55 PDT 2023


dwblaikie wrote:

> That's true, if defined in a header, we'll emit a DW_TAG_variable for the constant in each compile unit the header is included in. GCC does do the right thing and only emit the definition DIE in a single CU. We should probably do the same. Though not sure at which level we want to catch that.

Which variable are you discussing here, `val1` or `val2`?

For `val1`, we could not emit the constant value and only emit the real definition (there's /some/ risk here - non-ODR uses (or otherwise optimized away uses) of the variable may mean that the object file that defines the variable won't be linked in - so we'd miss the constant value)
For `val2` the variable is effectively `inline` and doesn't have a home, so there's no one place that we can emit the `DW_TAG_variable` out-of-line definition... 

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


More information about the cfe-commits mailing list