diff options
Diffstat (limited to 'unittests/CodeGen/DIEHashTest.cpp')
-rw-r--r-- | unittests/CodeGen/DIEHashTest.cpp | 200 |
1 files changed, 101 insertions, 99 deletions
diff --git a/unittests/CodeGen/DIEHashTest.cpp b/unittests/CodeGen/DIEHashTest.cpp index c874cef..04c5a8a 100644 --- a/unittests/CodeGen/DIEHashTest.cpp +++ b/unittests/CodeGen/DIEHashTest.cpp @@ -12,6 +12,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/Format.h" +#include "llvm/ADT/STLExtras.h" #include "gtest/gtest.h" using namespace llvm; @@ -59,7 +60,7 @@ TEST(DIEHashTest, NamedType) { TEST(DIEHashTest, NamespacedType) { DIE CU(dwarf::DW_TAG_compile_unit); - DIE *Space = new DIE(dwarf::DW_TAG_namespace); + auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace); DIEInteger One(1); DIEString SpaceStr(&One, "space"); Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &SpaceStr); @@ -67,15 +68,16 @@ TEST(DIEHashTest, NamespacedType) { Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One); // sibling? - DIE *Foo = new DIE(dwarf::DW_TAG_structure_type); + auto Foo = make_unique<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); - Space->addChild(Foo); - CU.addChild(Space); + DIE &N = *Foo; + Space->addChild(std::move(Foo)); + CU.addChild(std::move(Space)); - uint64_t MD5Res = DIEHash().computeTypeSignature(*Foo); + uint64_t MD5Res = DIEHash().computeTypeSignature(N); // The exact same hash GCC produces for this DIE. ASSERT_EQ(0x7b80381fd17f1e33ULL, MD5Res); @@ -87,15 +89,6 @@ TEST(DIEHashTest, TypeWithMember) { DIEInteger Four(4); Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four); - DIE *Member = new DIE(dwarf::DW_TAG_member); - DIEString MemberStr(&Four, "member"); - Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr); - DIEInteger Zero(0); - Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, - &Zero); - - Unnamed.addChild(Member); - DIE Int(dwarf::DW_TAG_base_type); DIEString IntStr(&Four, "int"); Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr); @@ -103,9 +96,18 @@ TEST(DIEHashTest, TypeWithMember) { DIEInteger Five(5); Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five); - DIEEntry IntRef(&Int); + DIEEntry IntRef(Int); + + auto Member = make_unique<DIE>(dwarf::DW_TAG_member); + DIEString MemberStr(&Four, "member"); + Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr); + DIEInteger Zero(0); + Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, + &Zero); Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef); + Unnamed.addChild(std::move(Member)); + uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); ASSERT_EQ(0x5646aa436b7e07c6ULL, MD5Res); @@ -117,35 +119,35 @@ TEST(DIEHashTest, ReusedType) { DIEInteger Eight(8); Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight); - DIE *Mem1 = new DIE(dwarf::DW_TAG_member); DIEInteger Four(4); + DIE Int(dwarf::DW_TAG_base_type); + DIEString IntStr(&Four, "int"); + Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr); + Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four); + DIEInteger Five(5); + Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five); + + DIEEntry IntRef(Int); + + auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member); DIEString Mem1Str(&Four, "mem1"); Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem1Str); DIEInteger Zero(0); Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero); + Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef); - Unnamed.addChild(Mem1); + Unnamed.addChild(std::move(Mem1)); - DIE *Mem2 = new DIE(dwarf::DW_TAG_member); + auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member); DIEString Mem2Str(&Four, "mem2"); Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem2Str); Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Four); - - Unnamed.addChild(Mem2); - - DIE Int(dwarf::DW_TAG_base_type); - DIEString IntStr(&Four, "int"); - Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr); - Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four); - DIEInteger Five(5); - Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five); - - DIEEntry IntRef(&Int); - Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef); Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef); + Unnamed.addChild(std::move(Mem2)); + uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); ASSERT_EQ(0x3a7dc3ed7b76b2f8ULL, MD5Res); @@ -159,14 +161,14 @@ TEST(DIEHashTest, RecursiveType) { DIEString FooStr(&One, "foo"); Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); - DIE *Mem = new DIE(dwarf::DW_TAG_member); + auto Mem = make_unique<DIE>(dwarf::DW_TAG_member); DIEString MemStr(&One, "mem"); Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr); - DIEEntry FooRef(&Foo); + DIEEntry FooRef(Foo); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef); // DW_AT_external and DW_AT_declaration are ignored anyway, so skip them. - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -181,7 +183,7 @@ TEST(DIEHashTest, Pointer) { DIEString FooStr(&Eight, "foo"); Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); - DIE *Mem = new DIE(dwarf::DW_TAG_member); + auto Mem = make_unique<DIE>(dwarf::DW_TAG_member); DIEString MemStr(&Eight, "mem"); Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr); DIEInteger Zero(0); @@ -189,13 +191,13 @@ TEST(DIEHashTest, Pointer) { DIE FooPtr(dwarf::DW_TAG_pointer_type); FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight); - DIEEntry FooRef(&Foo); + DIEEntry FooRef(Foo); FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef); - DIEEntry FooPtrRef(&FooPtr); + DIEEntry FooPtrRef(FooPtr); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooPtrRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -210,7 +212,7 @@ TEST(DIEHashTest, Reference) { DIEString FooStr(&Eight, "foo"); Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); - DIE *Mem = new DIE(dwarf::DW_TAG_member); + auto Mem = make_unique<DIE>(dwarf::DW_TAG_member); DIEString MemStr(&Eight, "mem"); Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr); DIEInteger Zero(0); @@ -218,17 +220,17 @@ TEST(DIEHashTest, Reference) { DIE FooRef(dwarf::DW_TAG_reference_type); FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight); - DIEEntry FooEntry(&Foo); + DIEEntry FooEntry(Foo); FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry); DIE FooRefConst(dwarf::DW_TAG_const_type); - DIEEntry FooRefRef(&FooRef); + DIEEntry FooRefRef(FooRef); FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef); - DIEEntry FooRefConstRef(&FooRefConst); + DIEEntry FooRefConstRef(FooRefConst); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -243,7 +245,7 @@ TEST(DIEHashTest, RValueReference) { DIEString FooStr(&Eight, "foo"); Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); - DIE *Mem = new DIE(dwarf::DW_TAG_member); + auto Mem = make_unique<DIE>(dwarf::DW_TAG_member); DIEString MemStr(&Eight, "mem"); Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr); DIEInteger Zero(0); @@ -251,17 +253,17 @@ TEST(DIEHashTest, RValueReference) { DIE FooRef(dwarf::DW_TAG_rvalue_reference_type); FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight); - DIEEntry FooEntry(&Foo); + DIEEntry FooEntry(Foo); FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry); DIE FooRefConst(dwarf::DW_TAG_const_type); - DIEEntry FooRefRef(&FooRef); + DIEEntry FooRefRef(FooRef); FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef); - DIEEntry FooRefConstRef(&FooRefConst); + DIEEntry FooRefConstRef(FooRefConst); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -276,22 +278,22 @@ TEST(DIEHashTest, PtrToMember) { DIEString FooStr(&Eight, "foo"); Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr); - DIE *Mem = new DIE(dwarf::DW_TAG_member); + auto Mem = make_unique<DIE>(dwarf::DW_TAG_member); DIEString MemStr(&Eight, "mem"); Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr); DIEInteger Zero(0); Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero); DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type); - DIEEntry FooEntry(&Foo); + DIEEntry FooEntry(Foo); PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry); PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, &FooEntry); - DIEEntry PtrToFooMemRef(&PtrToFooMem); + DIEEntry PtrToFooMemRef(PtrToFooMem); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -320,22 +322,22 @@ TEST(DIEHashTest, PtrToMemberDeclDefMatch) { 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); + auto Mem = make_unique<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 PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type); - DIEEntry BarEntry(&Bar); + DIEEntry BarEntry(Bar); PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry); - DIEEntry FooEntry(&Foo); + DIEEntry FooEntry(Foo); PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, &FooEntry); - DIEEntry PtrToFooMemRef(&PtrToFooMem); + DIEEntry PtrToFooMemRef(PtrToFooMem); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); MD5ResDecl = DIEHash().computeTypeSignature(Foo); } @@ -349,22 +351,22 @@ TEST(DIEHashTest, PtrToMemberDeclDefMatch) { 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); + auto Mem = make_unique<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 PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type); - DIEEntry BarEntry(&Bar); + DIEEntry BarEntry(Bar); PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry); - DIEEntry FooEntry(&Foo); + DIEEntry FooEntry(Foo); PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, &FooEntry); - DIEEntry PtrToFooMemRef(&PtrToFooMem); + DIEEntry PtrToFooMemRef(PtrToFooMem); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); MD5ResDef = DIEHash().computeTypeSignature(Foo); } @@ -393,21 +395,21 @@ TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) { 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); + auto Mem = make_unique<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 PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type); - DIEEntry BarEntry(&Bar); + DIEEntry BarEntry(Bar); PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry); PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, &BarEntry); - DIEEntry PtrToFooMemRef(&PtrToFooMem); + DIEEntry PtrToFooMemRef(PtrToFooMem); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); MD5ResDecl = DIEHash().computeTypeSignature(Foo); } @@ -421,21 +423,21 @@ TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) { 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); + auto Mem = make_unique<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 PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type); - DIEEntry BarEntry(&Bar); + DIEEntry BarEntry(Bar); PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry); PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, &BarEntry); - DIEEntry PtrToFooMemRef(&PtrToFooMem); + DIEEntry PtrToFooMemRef(PtrToFooMem); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); MD5ResDef = DIEHash().computeTypeSignature(Foo); } @@ -463,19 +465,19 @@ TEST(DIEHashTest, RefUnnamedType) { 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); + auto Mem = make_unique<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); + DIEEntry UnnamedRef(Unnamed); UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedRef); - DIEEntry UnnamedPtrRef(&UnnamedPtr); + DIEEntry UnnamedPtrRef(UnnamedPtr); Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef); - Foo.addChild(Mem); + Foo.addChild(std::move(Mem)); uint64_t MD5Res = DIEHash().computeTypeSignature(Foo); @@ -488,12 +490,12 @@ TEST(DIEHashTest, NestedType) { DIEInteger One(1); Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One); - DIE *Foo = new DIE(dwarf::DW_TAG_structure_type); + auto Foo = make_unique<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); + Unnamed.addChild(std::move(Foo)); uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); @@ -507,11 +509,11 @@ TEST(DIEHashTest, MemberFunc) { DIEInteger One(1); Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One); - DIE *Func = new DIE(dwarf::DW_TAG_subprogram); + auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram); DIEString FuncStr(&One, "func"); Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr); - Unnamed.addChild(Func); + Unnamed.addChild(std::move(Func)); uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed); @@ -531,7 +533,7 @@ TEST(DIEHashTest, MemberFuncFlag) { A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One); A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One); - DIE *Func = new DIE(dwarf::DW_TAG_subprogram); + auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram); DIEString FuncStr(&One, "func"); DIEString FuncLinkage(&One, "_ZN1A4funcEv"); DIEInteger Two(2); @@ -542,7 +544,7 @@ TEST(DIEHashTest, MemberFuncFlag) { Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, &FuncLinkage); Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One); - A.addChild(Func); + A.addChild(std::move(Func)); uint64_t MD5Res = DIEHash().computeTypeSignature(A); @@ -567,17 +569,17 @@ TEST(DIEHashTest, MemberSdata) { 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); + DIE IntTyDIE(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); + auto PITyDIE = make_unique<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); + DIEEntry PITy(*PITyDIE); + auto PI = make_unique<DIE>(dwarf::DW_TAG_member); DIEString PIStr(&One, "PI"); DIEInteger Two(2); DIEInteger NegThree(-3); @@ -589,7 +591,7 @@ TEST(DIEHashTest, MemberSdata) { 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.addChild(std::move(PI)); uint64_t MD5Res = DIEHash().computeTypeSignature(A); ASSERT_EQ(0x9a216000dd3788a7ULL, MD5Res); @@ -611,17 +613,17 @@ TEST(DIEHashTest, MemberBlock) { DIEInteger Four(4); DIEString FStr(&One, "float"); - DIE *FloatTyDIE = new DIE(dwarf::DW_TAG_base_type); + auto FloatTyDIE = make_unique<DIE>(dwarf::DW_TAG_base_type); FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four); FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Four); FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr); - DIEEntry FloatTy(FloatTyDIE); - DIE *PITyDIE = new DIE(dwarf::DW_TAG_const_type); + DIEEntry FloatTy(*FloatTyDIE); + auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type); PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FloatTy); - DIEEntry PITy(PITyDIE); - DIE *PI = new DIE(dwarf::DW_TAG_member); + DIEEntry PITy(*PITyDIE); + auto PI = make_unique<DIE>(dwarf::DW_TAG_member); DIEString PIStr(&One, "PI"); DIEInteger Two(2); PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr); @@ -631,20 +633,20 @@ TEST(DIEHashTest, MemberBlock) { PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One); PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One); - DIEBlock *PIBlock = new DIEBlock(); + DIEBlock PIBlock; DIEInteger Blk1(0xc3); DIEInteger Blk2(0xf5); DIEInteger Blk3(0x48); DIEInteger Blk4(0x40); - PIBlock->addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk1); - PIBlock->addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk2); - PIBlock->addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk3); - PIBlock->addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk4); + PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk1); + PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk2); + PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk3); + PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk4); - PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, PIBlock); + PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock); - A.addChild(PI); + A.addChild(std::move(PI)); uint64_t MD5Res = DIEHash().computeTypeSignature(A); ASSERT_EQ(0x493af53ad3d3f651ULL, MD5Res); |