1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Add support for hashing DW_FORM_sdata and a small testcase.

llvm-svn: 201747
This commit is contained in:
Eric Christopher 2014-02-20 00:54:40 +00:00
parent 45a3ce6871
commit 043a17a7b0
2 changed files with 48 additions and 0 deletions

View File

@ -306,6 +306,7 @@ void DIEHash::hashAttribute(AttrEntry Attr, dwarf::Tag Tag) {
case dwarf::DW_FORM_data4:
case dwarf::DW_FORM_data8:
case dwarf::DW_FORM_udata:
case dwarf::DW_FORM_sdata:
addULEB128('A');
addULEB128(Attribute);
addULEB128(dwarf::DW_FORM_sdata);

View File

@ -549,4 +549,51 @@ TEST(DIEHashTest, MemberFuncFlag) {
// The exact same hash GCC produces for this DIE.
ASSERT_EQ(0x8f78211ddce3df10ULL, MD5Res);
}
// Derived from:
// struct A {
// const static float PI = 3.14f;
// };
// A a;
TEST(DIEHashTest, MemberBlock) {
DIE A(dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString AStr(&One, "A");
A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
DIEInteger Four(4);
DIEInteger Five(5);
DIEString FStr(&One, "int");
DIE *IntTyDIE = new DIE(dwarf::DW_TAG_base_type);
IntTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
IntTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
IntTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
DIEEntry IntTy(IntTyDIE);
DIE *PITyDIE = new DIE(dwarf::DW_TAG_const_type);
PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntTy);
DIEEntry PITy(PITyDIE);
DIE *PI = new DIE(dwarf::DW_TAG_member);
DIEString PIStr(&One, "PI");
DIEInteger Two(2);
DIEInteger NegThree(-3);
PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, &NegThree);
A.addChild(PI);
A.dump();
uint64_t MD5Res = DIEHash().computeTypeSignature(A);
ASSERT_EQ(0x9a216000dd3788a7ULL, MD5Res);
}
}