llvm.org GIT mirror llvm / 1d7d8da
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 David Blaikie 7 years ago
2 changed file(s) with 42 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
241241 // there's a decl/def difference in the containing type of a
242242 // ptr_to_member_type, but it's what DWARF says, for some reason.
243243 Attribute == dwarf::DW_AT_type) {
244 // [FIXME] ... has a DW_AT_name attribute,
245 hashShallowTypeReference(Attribute, Entry,
246 getDIEStringAttr(Entry, dwarf::DW_AT_name));
247 return;
244 // ... has a DW_AT_name attribute,
245 StringRef Name = getDIEStringAttr(Entry, dwarf::DW_AT_name);
246 if (!Name.empty()) {
247 hashShallowTypeReference(Attribute, Entry, Name);
248 return;
249 }
248250 }
249251
250252 unsigned &DieNumber = Numbering[&Entry];
441441 // and a definition in another.
442442 ASSERT_NE(MD5ResDef, MD5ResDecl);
443443 }
444 }
444
445 // struct { } a;
446 // struct foo { decltype(a) mem; };
447 TEST(DIEHashTest, RefUnnamedType) {
448 DIEInteger Zero(0);
449 DIEInteger One(1);
450 DIEInteger Eight(8);
451 DIEString FooStr(&Zero, "foo");
452 DIEString MemStr(&Zero, "mem");
453
454 DIE Unnamed(dwarf::DW_TAG_structure_type);
455 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
456
457 DIE Foo(dwarf::DW_TAG_structure_type);
458 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
459 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
460
461 DIE *Mem = new DIE(dwarf::DW_TAG_member);
462 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
463 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
464
465 DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
466 UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
467 DIEEntry UnnamedRef(&Unnamed);
468 UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedRef);
469
470 DIEEntry UnnamedPtrRef(&UnnamedPtr);
471 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef);
472
473 Foo.addChild(Mem);
474
475 uint64_t MD5Res = DIEHash().computeTypeSignature(&Foo);
476
477 ASSERT_EQ(0x954e026f01c02529ULL, MD5Res);
478 }
479 }