diff options
Diffstat (limited to 'llvm/unittests/CodeGen/DIEHashTest.cpp')
-rw-r--r-- | llvm/unittests/CodeGen/DIEHashTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/DIEHashTest.cpp b/llvm/unittests/CodeGen/DIEHashTest.cpp index 6f71462bfdf..fb6f4b3640a 100644 --- a/llvm/unittests/CodeGen/DIEHashTest.cpp +++ b/llvm/unittests/CodeGen/DIEHashTest.cpp @@ -477,4 +477,23 @@ TEST(DIEHashTest, RefUnnamedType) { ASSERT_EQ(0x954e026f01c02529ULL, MD5Res); } + +// struct { struct bar { }; }; +TEST(DIEHashTest, NestedType) { + DIE Unnamed(dwarf::DW_TAG_structure_type); + DIEInteger One(1); + Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One); + + DIE *Foo = new DIE(dwarf::DW_TAG_structure_type); + DIEString FooStr(&One, "foo"); + Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); + Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One); + + Unnamed.addChild(Foo); + + uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); + + // The exact same hash GCC produces for this DIE. + ASSERT_EQ(0xde8a3b7b43807f4aULL, MD5Res); +} } |