Issue 166673
Summary [llvm] [debuginfo] `DW_TAG_typedef` generated by `clang::preferred_name` has wrong `DW_AT_decl_line` DW_AT_decl_line` value
Labels clang
Assignees
Reporter royitaqi
    (This is on macOS. Not sure what it does on Linux.)

See this code:
```
template <typename T> struct Foo;

typedef Foo<int> BarInt;

template <typename T>
struct [[clang::preferred_name(BarInt)]] Foo{};

int main() {
  BarInt barInt;
  return 0;
}
```

Compile it with `xcrun clang++ -g -O0 -c`.

The generated object file contains these two DIEs:
```
0x00000044:   DW_TAG_typedef
 DW_AT_type	(0x0000004c "BarInt")
 DW_AT_name	("BarInt")
 DW_AT_decl_file	("/Users/royshi/demo/preferred_name/one.cpp")
 DW_AT_decl_line	(3)

0x0000004c:   DW_TAG_typedef
 DW_AT_type	(0x00000054 "Foo<int>")
 DW_AT_name	("BarInt")
 DW_AT_decl_file	("/Users/royshi/demo/preferred_name/one.cpp")
 DW_AT_decl_line	(3)
```

The first DIE is generated by `[[clang::preferred_name(BarInt)]]` on line 6. You can prove this by removing the attribute from the source code and recompiling, after which this DIE will disappear.

The problem is that the attribute is on line 6, so the `DW_AT_decl_line` here should be `6`, not `3`.

--

Fixing this will help fix the self-recursive typedef DIE issue (https://github.com/llvm/llvm-project/issues/162954), because then the two DIE will have different decl lines, which we can use in their synthetic names to differentiate them, so that they won't be merged together by the parallel linker.

cc @Michael137, @avl-llvm, @clayborg 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to