Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,10 @@ Error SyntheticTypeNameBuilder::addTypeName(UnitEntryPairTy InputUnitEntryPair,
} break;
}

// If name for the DIE is not determined yet add referenced types to the name.
if (!HasLinkageName && !HasShortName && !HasDeclFileName) {
// If name for the DIE is not determined yet or if the DIE is a typedef, add
// referenced types to the name.
if ((!HasLinkageName && !HasShortName && !HasDeclFileName) ||
InputUnitEntryPair.DieEntry->getTag() == dwarf::DW_TAG_typedef) {
if (InputUnitEntryPair.CU->find(InputUnitEntryPair.DieEntry,
getODRAttributes()))
if (Error Err = addReferencedODRDies(InputUnitEntryPair, AddParentNames,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ void foo() { Sptrptr ptr1 = 0; }
// CHECK: DW_TAG_member
// CHECK-NEXT: DW_AT_name{{.*}}"field"

// CHECK: 0x[[TYPEDEF_PTR_S]]: DW_TAG_typedef
// CHECK-NEXT: DW_AT_type{{.*}}{0x[[PTR_S]]} "S *"
// CHECK-NEXT: DW_AT_name{{.*}}"Sptr"

// CHECK: 0x[[TYPEDEF_PTR_PTR_S:[a-f0-9]*]]: DW_TAG_typedef
// CHECK-NEXT: DW_AT_type{{.*}}{0x[[PTR_PTR_S]]} "Sptr *"
// CHECK-NEXT: DW_AT_name{{.*}}"Sptrptr"

// CHECK: 0x[[TYPEDEF_PTR_S]]: DW_TAG_typedef
// CHECK-NEXT: DW_AT_type{{.*}}{0x[[PTR_S]]} "S *"
// CHECK-NEXT: DW_AT_name{{.*}}"Sptr"

// First we confirm that first compile unit properly references type.
//
// CHECK: DW_TAG_compile_unit
Expand Down
41 changes: 41 additions & 0 deletions llvm/test/tools/dsymutil/typedefs-with-same-name.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#RUN: dsymutil --linker=parallel -f -oso-prepend-path=%p/Inputs/ -y %s -o %t.dwarf
#RUN: llvm-dwarfdump %t.dwarf | FileCheck %s

# There should be two typedef DIE named "BarInt" in the resultant .dwarf file.
# The second should refer to the first, which refer to "Foo<int>".
# CHECK: 0x[[FIRST_BARINT_ADDR:[0-9a-f]*]]: DW_TAG_typedef
# CHECK-NEXT: DW_AT_type (0x{{([[:xdigit:]]*)}} "Foo<int>")
# CHECK-NEXT: DW_AT_name ("BarInt")
# CHECK: 0x{{([[:xdigit:]]*)}}: DW_TAG_typedef
# CHECK-NEXT: DW_AT_type (0x[[FIRST_BARINT_ADDR]] "BarInt")
# CHECK-NEXT: DW_AT_name ("BarInt")

# Source:
#
# 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 with:
#
# $ clang++ -g -O0 -c typedefs-with-same-name.cpp -o typedefs-with-same-name.o
#
# To generate the debug map:
#
# $ clang++ typedefs-with-same-name.o -o typedefs-with-same-name
# $ dsymutil -dump-debug-map typedefs-with-same-name

---
triple: 'arm64-apple-darwin'
objects:
- filename: '/typedefs-with-same-name.o'
timestamp: 1762438746
type: 102
symbols:
- { sym: _main, objAddr: 0x0, binAddr: 0x100000360, size: 0x14 }
...