mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
DIEHash: Do not use shallow type hashing for unnamed types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193361 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
851aa948cb
commit
1d7d8da4cb
@ -242,10 +242,12 @@ void DIEHash::hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
|
||||
// there's a decl/def difference in the containing type of a
|
||||
// ptr_to_member_type, but it's what DWARF says, for some reason.
|
||||
Attribute == dwarf::DW_AT_type) {
|
||||
// [FIXME] ... has a DW_AT_name attribute,
|
||||
hashShallowTypeReference(Attribute, Entry,
|
||||
getDIEStringAttr(Entry, dwarf::DW_AT_name));
|
||||
return;
|
||||
// ... has a DW_AT_name attribute,
|
||||
StringRef Name = getDIEStringAttr(Entry, dwarf::DW_AT_name);
|
||||
if (!Name.empty()) {
|
||||
hashShallowTypeReference(Attribute, Entry, Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned &DieNumber = Numbering[&Entry];
|
||||
|
@ -442,4 +442,39 @@ TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) {
|
||||
// and a definition in another.
|
||||
ASSERT_NE(MD5ResDef, MD5ResDecl);
|
||||
}
|
||||
|
||||
// struct { } a;
|
||||
// struct foo { decltype(a) mem; };
|
||||
TEST(DIEHashTest, RefUnnamedType) {
|
||||
DIEInteger Zero(0);
|
||||
DIEInteger One(1);
|
||||
DIEInteger Eight(8);
|
||||
DIEString FooStr(&Zero, "foo");
|
||||
DIEString MemStr(&Zero, "mem");
|
||||
|
||||
DIE Unnamed(dwarf::DW_TAG_structure_type);
|
||||
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
|
||||
|
||||
DIE Foo(dwarf::DW_TAG_structure_type);
|
||||
Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
||||
Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
|
||||
|
||||
DIE *Mem = new DIE(dwarf::DW_TAG_member);
|
||||
Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
|
||||
Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
|
||||
|
||||
DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
|
||||
UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
|
||||
DIEEntry UnnamedRef(&Unnamed);
|
||||
UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedRef);
|
||||
|
||||
DIEEntry UnnamedPtrRef(&UnnamedPtr);
|
||||
Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef);
|
||||
|
||||
Foo.addChild(Mem);
|
||||
|
||||
uint64_t MD5Res = DIEHash().computeTypeSignature(&Foo);
|
||||
|
||||
ASSERT_EQ(0x954e026f01c02529ULL, MD5Res);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user