summaryrefslogtreecommitdiffstats
path: root/unittests/CodeGen/DIEHashTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/CodeGen/DIEHashTest.cpp')
-rw-r--r--unittests/CodeGen/DIEHashTest.cpp481
1 files changed, 256 insertions, 225 deletions
diff --git a/unittests/CodeGen/DIEHashTest.cpp b/unittests/CodeGen/DIEHashTest.cpp
index 8e78f0c..e3a9e56 100644
--- a/unittests/CodeGen/DIEHashTest.cpp
+++ b/unittests/CodeGen/DIEHashTest.cpp
@@ -22,6 +22,10 @@ namespace {
// Test fixture
class DIEHashTest : public testing::Test {
+public:
+ BumpPtrAllocator Alloc;
+
+private:
StringMap<DwarfStringPoolEntry> Pool;
public:
@@ -34,22 +38,22 @@ public:
TEST_F(DIEHashTest, Data1) {
DIEHash Hash;
- DIE Die(dwarf::DW_TAG_base_type);
+ DIE &Die = *DIE::get(Alloc, dwarf::DW_TAG_base_type);
DIEInteger Size(4);
- Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
+ Die.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Size);
uint64_t MD5Res = Hash.computeTypeSignature(Die);
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
}
// struct {};
TEST_F(DIEHashTest, TrivialType) {
- DIE Unnamed(dwarf::DW_TAG_structure_type);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
// Line and file number are ignored.
- Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
- Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
// The exact same hash GCC produces for this DIE.
@@ -58,11 +62,11 @@ TEST_F(DIEHashTest, TrivialType) {
// struct foo { };
TEST_F(DIEHashTest, NamedType) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
@@ -72,20 +76,21 @@ TEST_F(DIEHashTest, NamedType) {
// namespace space { struct foo { }; }
TEST_F(DIEHashTest, NamespacedType) {
- DIE CU(dwarf::DW_TAG_compile_unit);
+ DIE &CU = *DIE::get(Alloc, dwarf::DW_TAG_compile_unit);
- auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace);
+ auto Space = DIE::get(Alloc, dwarf::DW_TAG_namespace);
DIEInteger One(1);
DIEString SpaceStr = getString("space");
- Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
+ Space->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, SpaceStr);
// DW_AT_declaration is ignored.
- Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
+ Space->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
// sibling?
- auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
+ auto Foo = DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEString FooStr = getString("foo");
- Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
DIE &N = *Foo;
Space->addChild(std::move(Foo));
@@ -99,26 +104,26 @@ TEST_F(DIEHashTest, NamespacedType) {
// struct { int member; };
TEST_F(DIEHashTest, TypeWithMember) {
- DIE Unnamed(dwarf::DW_TAG_structure_type);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Four(4);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
- DIE Int(dwarf::DW_TAG_base_type);
+ DIE &Int = *DIE::get(Alloc, dwarf::DW_TAG_base_type);
DIEString IntStr = getString("int");
- Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
- Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
+ Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
+ Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
DIEInteger Five(5);
- Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
+ Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
DIEEntry IntRef(Int);
- auto Member = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Member = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemberStr = getString("member");
- Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemberStr);
+ Member->addValue(Alloc, 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);
+ Member->addValue(Alloc, dwarf::DW_AT_data_member_location,
+ dwarf::DW_FORM_data1, Zero);
+ Member->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
Unnamed.addChild(std::move(Member));
@@ -129,36 +134,36 @@ TEST_F(DIEHashTest, TypeWithMember) {
// struct foo { int mem1, mem2; };
TEST_F(DIEHashTest, ReusedType) {
- DIE Unnamed(dwarf::DW_TAG_structure_type);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEInteger Four(4);
- DIE Int(dwarf::DW_TAG_base_type);
+ DIE &Int = *DIE::get(Alloc, dwarf::DW_TAG_base_type);
DIEString IntStr = getString("int");
- Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
- Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
+ Int.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, IntStr);
+ Int.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
DIEInteger Five(5);
- Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
+ Int.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
DIEEntry IntRef(Int);
- auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem1 = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString Mem1Str = getString("mem1");
- Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
+ Mem1->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem1Str);
DIEInteger Zero(0);
- Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Mem1->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
Zero);
- Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
+ Mem1->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
Unnamed.addChild(std::move(Mem1));
- auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem2 = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString Mem2Str = getString("mem2");
- Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
- Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Mem2->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, Mem2Str);
+ Mem2->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
Four);
- Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
+ Mem2->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntRef);
Unnamed.addChild(std::move(Mem2));
@@ -169,17 +174,17 @@ TEST_F(DIEHashTest, ReusedType) {
// struct foo { static foo f; };
TEST_F(DIEHashTest, RecursiveType) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemStr = getString("mem");
- Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
DIEEntry FooRef(Foo);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
// DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
Foo.addChild(std::move(Mem));
@@ -191,25 +196,26 @@ TEST_F(DIEHashTest, RecursiveType) {
// struct foo { foo *mem; };
TEST_F(DIEHashTest, Pointer) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemStr = getString("mem");
- Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, 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);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Zero);
- DIE FooPtr(dwarf::DW_TAG_pointer_type);
- FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ DIE &FooPtr = *DIE::get(Alloc, dwarf::DW_TAG_pointer_type);
+ FooPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEEntry FooRef(Foo);
- FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
+ FooPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRef);
DIEEntry FooPtrRef(FooPtr);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooPtrRef);
Foo.addChild(std::move(Mem));
@@ -220,29 +226,31 @@ TEST_F(DIEHashTest, Pointer) {
// struct foo { foo &mem; };
TEST_F(DIEHashTest, Reference) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemStr = getString("mem");
- Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, 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);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Zero);
- DIE FooRef(dwarf::DW_TAG_reference_type);
- FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ DIE &FooRef = *DIE::get(Alloc, dwarf::DW_TAG_reference_type);
+ FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEEntry FooEntry(Foo);
- FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
+ FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
- DIE FooRefConst(dwarf::DW_TAG_const_type);
+ DIE &FooRefConst = *DIE::get(Alloc, dwarf::DW_TAG_const_type);
DIEEntry FooRefRef(FooRef);
- FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
+ FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ FooRefRef);
DIEEntry FooRefConstRef(FooRefConst);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
Foo.addChild(std::move(Mem));
@@ -253,29 +261,31 @@ TEST_F(DIEHashTest, Reference) {
// struct foo { foo &&mem; };
TEST_F(DIEHashTest, RValueReference) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemStr = getString("mem");
- Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, 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);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Zero);
- DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
- FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ DIE &FooRef = *DIE::get(Alloc, dwarf::DW_TAG_rvalue_reference_type);
+ FooRef.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEEntry FooEntry(Foo);
- FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
+ FooRef.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
- DIE FooRefConst(dwarf::DW_TAG_const_type);
+ DIE &FooRefConst = *DIE::get(Alloc, dwarf::DW_TAG_const_type);
DIEEntry FooRefRef(FooRef);
- FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefRef);
+ FooRefConst.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ FooRefRef);
DIEEntry FooRefConstRef(FooRefConst);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooRefConstRef);
Foo.addChild(std::move(Mem));
@@ -286,26 +296,27 @@ TEST_F(DIEHashTest, RValueReference) {
// struct foo { foo foo::*mem; };
TEST_F(DIEHashTest, PtrToMember) {
- DIE Foo(dwarf::DW_TAG_structure_type);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
DIEString FooStr = getString("foo");
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString MemStr = getString("mem");
- Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, 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);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
+ Zero);
- DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
+ DIE &PtrToFooMem = *DIE::get(Alloc, dwarf::DW_TAG_ptr_to_member_type);
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,
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FooEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
FooEntry);
DIEEntry PtrToFooMemRef(PtrToFooMem);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
Foo.addChild(std::move(Mem));
@@ -328,28 +339,31 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMatch) {
DIEString MemStr = getString("mem");
uint64_t MD5ResDecl;
{
- DIE Bar(dwarf::DW_TAG_structure_type);
- Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
- Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
+ DIE &Bar = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
+ Bar.addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
- DIE Foo(dwarf::DW_TAG_structure_type);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- 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);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
+ dwarf::DW_FORM_data1, Zero);
- DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
+ DIE &PtrToFooMem = *DIE::get(Alloc, dwarf::DW_TAG_ptr_to_member_type);
DIEEntry BarEntry(Bar);
- PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ BarEntry);
DIEEntry FooEntry(Foo);
- PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
- FooEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
+ dwarf::DW_FORM_ref4, FooEntry);
DIEEntry PtrToFooMemRef(PtrToFooMem);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ PtrToFooMemRef);
Foo.addChild(std::move(Mem));
@@ -357,28 +371,30 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMatch) {
}
uint64_t MD5ResDef;
{
- DIE Bar(dwarf::DW_TAG_structure_type);
- Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
- Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ DIE &Bar = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
+ Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
- DIE Foo(dwarf::DW_TAG_structure_type);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- 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);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
+ dwarf::DW_FORM_data1, Zero);
- DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
+ DIE &PtrToFooMem = *DIE::get(Alloc, dwarf::DW_TAG_ptr_to_member_type);
DIEEntry BarEntry(Bar);
- PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, BarEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ BarEntry);
DIEEntry FooEntry(Foo);
- PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
- FooEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
+ dwarf::DW_FORM_ref4, FooEntry);
DIEEntry PtrToFooMemRef(PtrToFooMem);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ PtrToFooMemRef);
Foo.addChild(std::move(Mem));
@@ -401,27 +417,30 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMisMatch) {
DIEString MemStr = getString("mem");
uint64_t MD5ResDecl;
{
- DIE Bar(dwarf::DW_TAG_structure_type);
- Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
- Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
+ DIE &Bar = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
+ Bar.addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
- DIE Foo(dwarf::DW_TAG_structure_type);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- 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);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
+ dwarf::DW_FORM_data1, Zero);
- DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
+ DIE &PtrToFooMem = *DIE::get(Alloc, dwarf::DW_TAG_ptr_to_member_type);
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,
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
BarEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
+ dwarf::DW_FORM_ref4, BarEntry);
DIEEntry PtrToFooMemRef(PtrToFooMem);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ PtrToFooMemRef);
Foo.addChild(std::move(Mem));
@@ -429,27 +448,29 @@ TEST_F(DIEHashTest, PtrToMemberDeclDefMisMatch) {
}
uint64_t MD5ResDef;
{
- DIE Bar(dwarf::DW_TAG_structure_type);
- Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
- Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ DIE &Bar = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Bar.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, BarStr);
+ Bar.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
- DIE Foo(dwarf::DW_TAG_structure_type);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- 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);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, dwarf::DW_AT_data_member_location,
+ dwarf::DW_FORM_data1, Zero);
- DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
+ DIE &PtrToFooMem = *DIE::get(Alloc, dwarf::DW_TAG_ptr_to_member_type);
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,
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
BarEntry);
+ PtrToFooMem.addValue(Alloc, dwarf::DW_AT_containing_type,
+ dwarf::DW_FORM_ref4, BarEntry);
DIEEntry PtrToFooMemRef(PtrToFooMem);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PtrToFooMemRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ PtrToFooMemRef);
Foo.addChild(std::move(Mem));
@@ -472,24 +493,27 @@ TEST_F(DIEHashTest, RefUnnamedType) {
DIEString FooStr = getString("foo");
DIEString MemStr = getString("mem");
- DIE Unnamed(dwarf::DW_TAG_structure_type);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
- DIE Foo(dwarf::DW_TAG_structure_type);
- Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
- Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ DIE &Foo = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
+ Foo.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Eight);
+ Foo.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- 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);
+ auto Mem = DIE::get(Alloc, dwarf::DW_TAG_member);
+ Mem->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, MemStr);
+ Mem->addValue(Alloc, 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);
+ DIE &UnnamedPtr = *DIE::get(Alloc, dwarf::DW_TAG_pointer_type);
+ UnnamedPtr.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
+ Eight);
DIEEntry UnnamedRef(Unnamed);
- UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedRef);
+ UnnamedPtr.addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4,
+ UnnamedRef);
DIEEntry UnnamedPtrRef(UnnamedPtr);
- Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
+ Mem->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, UnnamedPtrRef);
Foo.addChild(std::move(Mem));
@@ -500,14 +524,14 @@ TEST_F(DIEHashTest, RefUnnamedType) {
// struct { struct foo { }; };
TEST_F(DIEHashTest, NestedType) {
- DIE Unnamed(dwarf::DW_TAG_structure_type);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
- auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
+ auto Foo = DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEString FooStr = getString("foo");
- Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
- Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Foo->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FooStr);
+ Foo->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
Unnamed.addChild(std::move(Foo));
@@ -519,13 +543,13 @@ TEST_F(DIEHashTest, NestedType) {
// struct { static void func(); };
TEST_F(DIEHashTest, MemberFunc) {
- DIE Unnamed(dwarf::DW_TAG_structure_type);
+ DIE &Unnamed = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
- Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ Unnamed.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
- auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
+ auto Func = DIE::get(Alloc, dwarf::DW_TAG_subprogram);
DIEString FuncStr = getString("func");
- Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
+ Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
Unnamed.addChild(std::move(Func));
@@ -539,24 +563,27 @@ TEST_F(DIEHashTest, MemberFunc) {
// static void func();
// };
TEST_F(DIEHashTest, MemberFuncFlag) {
- DIE A(dwarf::DW_TAG_structure_type);
+ DIE &A = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString AStr = getString("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);
+ A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
+ A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
- auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
+ auto Func = DIE::get(Alloc, dwarf::DW_TAG_subprogram);
DIEString FuncStr = getString("func");
DIEString FuncLinkage = getString("_ZN1A4funcEv");
DIEInteger Two(2);
- Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
- Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
- Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
- Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
- Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, FuncLinkage);
- Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, One);
+ Func->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present,
+ One);
+ Func->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FuncStr);
+ Func->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ Func->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
+ Func->addValue(Alloc, dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp,
+ FuncLinkage);
+ Func->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
A.addChild(std::move(Func));
@@ -572,38 +599,39 @@ TEST_F(DIEHashTest, MemberFuncFlag) {
// };
// A a;
TEST_F(DIEHashTest, MemberSdata) {
- DIE A(dwarf::DW_TAG_structure_type);
+ DIE &A = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString AStr = getString("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);
+ A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
+ A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
DIEInteger Four(4);
DIEInteger Five(5);
DIEString FStr = getString("int");
- 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);
+ DIE &IntTyDIE = *DIE::get(Alloc, dwarf::DW_TAG_base_type);
+ IntTyDIE.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, Four);
+ IntTyDIE.addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Five);
+ IntTyDIE.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
DIEEntry IntTy(IntTyDIE);
- auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
- PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
+ auto PITyDIE = DIE::get(Alloc, dwarf::DW_TAG_const_type);
+ PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IntTy);
DIEEntry PITy(*PITyDIE);
- auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto PI = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString PIStr = getString("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);
+ PI->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
+ PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
+ PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
+ PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
+ PI->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
+ PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, NegThree);
A.addChild(std::move(PI));
@@ -617,35 +645,37 @@ TEST_F(DIEHashTest, MemberSdata) {
// };
// A a;
TEST_F(DIEHashTest, MemberBlock) {
- DIE A(dwarf::DW_TAG_structure_type);
+ DIE &A = *DIE::get(Alloc, dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString AStr = getString("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);
+ A.addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, AStr);
+ A.addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ A.addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, One);
DIEInteger Four(4);
DIEString FStr = getString("float");
- 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);
-
+ auto FloatTyDIE = DIE::get(Alloc, dwarf::DW_TAG_base_type);
+ FloatTyDIE->addValue(Alloc, dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1,
+ Four);
+ FloatTyDIE->addValue(Alloc, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
+ Four);
+ FloatTyDIE->addValue(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, FStr);
DIEEntry FloatTy(*FloatTyDIE);
- auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
- PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
+ auto PITyDIE = DIE::get(Alloc, dwarf::DW_TAG_const_type);
+ PITyDIE->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, FloatTy);
DIEEntry PITy(*PITyDIE);
- auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
+ auto PI = DIE::get(Alloc, dwarf::DW_TAG_member);
DIEString PIStr = getString("PI");
DIEInteger Two(2);
- 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(Alloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp, PIStr);
+ PI->addValue(Alloc, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, One);
+ PI->addValue(Alloc, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, Two);
+ PI->addValue(Alloc, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, PITy);
+ PI->addValue(Alloc, dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, One);
+ PI->addValue(Alloc, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present,
+ One);
DIEBlock PIBlock;
DIEInteger Blk1(0xc3);
@@ -653,12 +683,13 @@ TEST_F(DIEHashTest, MemberBlock) {
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(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk1);
+ PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk2);
+ PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk3);
+ PIBlock.addValue(Alloc, (dwarf::Attribute)0, dwarf::DW_FORM_data1, Blk4);
- PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
+ PI->addValue(Alloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_block1,
+ &PIBlock);
A.addChild(std::move(PI));
OpenPOWER on IntegriCloud