llvm.org GIT mirror llvm / f5334f2
Add support for hashing DW_FORM_sdata and a small testcase. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201747 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 6 years ago
2 changed file(s) with 49 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
305305 case dwarf::DW_FORM_data4:
306306 case dwarf::DW_FORM_data8:
307307 case dwarf::DW_FORM_udata:
308 case dwarf::DW_FORM_sdata:
308309 addULEB128('A');
309310 addULEB128(Attribute);
310311 addULEB128(dwarf::DW_FORM_sdata);
548548 // The exact same hash GCC produces for this DIE.
549549 ASSERT_EQ(0x8f78211ddce3df10ULL, MD5Res);
550550 }
551 }
551
552 // Derived from:
553 // struct A {
554 // const static float PI = 3.14f;
555 // };
556 // A a;
557 TEST(DIEHashTest, MemberBlock) {
558 DIE A(dwarf::DW_TAG_structure_type);
559 DIEInteger One(1);
560 DIEString AStr(&One, "A");
561 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
562 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
563 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
564 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
565
566 DIEInteger Four(4);
567 DIEInteger Five(5);
568 DIEString FStr(&One, "int");
569 DIE *IntTyDIE = new DIE(dwarf::DW_TAG_base_type);
570 IntTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
571 IntTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
572 IntTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
573
574 DIEEntry IntTy(IntTyDIE);
575 DIE *PITyDIE = new DIE(dwarf::DW_TAG_const_type);
576 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntTy);
577
578 DIEEntry PITy(PITyDIE);
579 DIE *PI = new DIE(dwarf::DW_TAG_member);
580 DIEString PIStr(&One, "PI");
581 DIEInteger Two(2);
582 DIEInteger NegThree(-3);
583 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
584 PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
585 PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
586 PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
587 PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
588 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
589 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, &NegThree);
590
591 A.addChild(PI);
592
593 A.dump();
594
595 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
596 ASSERT_EQ(0x9a216000dd3788a7ULL, MD5Res);
597 }
598 }