DIE: Pass ownership of children via std::unique_ptr rather than raw pointer.

This should reduce the chance of memory leaks like those fixed in
r207240.

There's still some unclear ownership of DIEs happening in DwarfDebug.
Pushing unique_ptr and references through more APIs should help expose
the cases where ownership is a bit fuzzy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-04-25 20:00:34 +00:00
parent 172515f0be
commit 12d5224df6
6 changed files with 106 additions and 100 deletions

View File

@ -172,11 +172,11 @@ public:
/// addChild - Add a child to the DIE.
///
void addChild(DIE *Child) {
void addChild(std::unique_ptr<DIE> Child) {
assert(!Child->getParent());
Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
Children.push_back(std::unique_ptr<DIE>(Child));
Child->Parent = this;
Children.push_back(std::move(Child));
}
/// findAttribute - Find a value in the DIE with the attribute given,

View File

@ -506,20 +506,21 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
return ScopeDIE;
}
DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU,
LexicalScope *Scope,
SmallVectorImpl<DIE *> &Children) {
DIE *DwarfDebug::createScopeChildrenDIE(
DwarfCompileUnit &TheCU, LexicalScope *Scope,
SmallVectorImpl<std::unique_ptr<DIE>> &Children) {
DIE *ObjectPointer = nullptr;
// Collect arguments for current function.
if (LScopes.isCurrentFunctionScope(Scope)) {
for (DbgVariable *ArgDV : CurrentFnArguments)
if (ArgDV)
if (DIE *Arg =
TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
Children.push_back(Arg);
if (ArgDV) {
std::unique_ptr<DIE> Arg =
TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope());
assert(Arg);
if (ArgDV->isObjectPointer())
ObjectPointer = Arg;
ObjectPointer = Arg.get();
Children.push_back(std::move(Arg));
}
// If this is a variadic function, add an unspecified parameter.
@ -527,22 +528,23 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU,
DIArray FnArgs = SP.getType().getTypeArray();
if (FnArgs.getElement(FnArgs.getNumElements() - 1)
.isUnspecifiedParameter()) {
DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
Children.push_back(Ellipsis);
Children.push_back(
make_unique<DIE>(dwarf::DW_TAG_unspecified_parameters));
}
}
// Collect lexical scope children first.
for (DbgVariable *DV : ScopeVariables.lookup(Scope))
if (DIE *Variable =
TheCU.constructVariableDIE(*DV, Scope->isAbstractScope())) {
Children.push_back(Variable);
for (DbgVariable *DV : ScopeVariables.lookup(Scope)) {
std::unique_ptr<DIE> Variable =
TheCU.constructVariableDIE(*DV, Scope->isAbstractScope());
assert(Variable);
Children.push_back(std::move(Variable));
if (DV->isObjectPointer())
ObjectPointer = Variable;
ObjectPointer = Variable.get();
}
for (LexicalScope *LS : Scope->getChildren())
if (DIE *Nested = constructScopeDIE(TheCU, LS))
Children.push_back(Nested);
Children.push_back(std::unique_ptr<DIE>(Nested));
return ObjectPointer;
}
@ -554,7 +556,7 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU,
DIScope DS(Scope->getScopeNode());
SmallVector<DIE *, 8> Children;
SmallVector<std::unique_ptr<DIE>, 8> Children;
DIE *ObjectPointer = nullptr;
bool ChildrenCreated = false;
@ -610,8 +612,8 @@ DIE *DwarfDebug::constructScopeDIE(DwarfCompileUnit &TheCU,
ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
// Add children
for (DIE *I : Children)
ScopeDIE->addChild(I);
for (auto &I : Children)
ScopeDIE->addChild(std::move(I));
if (DS.isSubprogram() && ObjectPointer != nullptr)
TheCU.addDIEEntry(*ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
@ -862,8 +864,7 @@ void DwarfDebug::collectDeadVariables() {
if (!DV.isVariable())
continue;
DbgVariable NewVar(DV, nullptr, this);
if (DIE *VariableDIE = SPCU->constructVariableDIE(NewVar, false))
SPDIE->addChild(VariableDIE);
SPDIE->addChild(SPCU->constructVariableDIE(NewVar, false));
}
}
}

View File

@ -367,7 +367,7 @@ class DwarfDebug : public AsmPrinterHandler {
DIE *constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
/// A helper function to create children of a Scope DIE.
DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
SmallVectorImpl<DIE *> &Children);
SmallVectorImpl<std::unique_ptr<DIE>> &Children);
/// \brief Emit initial Dwarf sections with a label at the start of each one.
void emitSectionLabels();

View File

@ -383,7 +383,7 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute,
DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N) {
assert(Tag != dwarf::DW_TAG_auto_variable &&
Tag != dwarf::DW_TAG_arg_variable);
Parent.addChild(new DIE((dwarf::Tag)Tag));
Parent.addChild(make_unique<DIE>((dwarf::Tag)Tag));
DIE &Die = *Parent.getChildren().back();
if (N)
insertDIE(N, &Die);
@ -1793,18 +1793,19 @@ void DwarfUnit::constructContainingTypeDIEs() {
}
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
std::unique_ptr<DIE> DwarfUnit::constructVariableDIE(DbgVariable &DV,
bool isScopeAbstract) {
auto D = constructVariableDIEImpl(DV, isScopeAbstract);
DV.setDIE(*D);
return D;
}
DIE *DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
bool isScopeAbstract) {
StringRef Name = DV.getName();
// Define variable debug information entry.
DIE *VariableDie = new DIE(DV.getTag());
auto VariableDie = make_unique<DIE>(DV.getTag());
DbgVariable *AbsVar = DV.getAbstractVariable();
DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : nullptr;
if (AbsDIE)

View File

@ -270,7 +270,7 @@ public:
/// addDie - Adds or interns the DIE to the compile unit.
///
void addDie(DIE *Buffer) { UnitDie->addChild(Buffer); }
void addDie(DIE *Buffer) { UnitDie->addChild(std::unique_ptr<DIE>(Buffer)); }
/// addFlag - Add a flag that is true to the DIE.
void addFlag(DIE &Die, dwarf::Attribute Attribute);
@ -425,7 +425,8 @@ public:
void constructContainingTypeDIEs();
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
bool isScopeAbstract);
/// constructSubprogramArguments - Construct function argument DIEs.
void constructSubprogramArguments(DIE &Buffer, DIArray Args);
@ -459,7 +460,8 @@ protected:
private:
/// \brief Construct a DIE for the given DbgVariable without initializing the
/// DbgVariable's DIE reference.
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool isScopeAbstract);
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
bool isScopeAbstract);
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);

View File

@ -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);
@ -104,8 +97,17 @@ TEST(DIEHashTest, TypeWithMember) {
Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
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,24 +119,7 @@ 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);
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);
Unnamed.addChild(Mem1);
DIE *Mem2 = new 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);
@ -143,9 +128,26 @@ TEST(DIEHashTest, ReusedType) {
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(std::move(Mem1));
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);
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);
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);
@ -195,7 +197,7 @@ TEST(DIEHashTest, Pointer) {
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);
@ -228,7 +230,7 @@ TEST(DIEHashTest, Reference) {
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);
@ -261,7 +263,7 @@ TEST(DIEHashTest, RValueReference) {
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,7 +278,7 @@ 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);
@ -291,7 +293,7 @@ TEST(DIEHashTest, PtrToMember) {
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,7 +322,7 @@ 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);
@ -335,7 +337,7 @@ TEST(DIEHashTest, PtrToMemberDeclDefMatch) {
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,7 +351,7 @@ 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);
@ -364,7 +366,7 @@ TEST(DIEHashTest, PtrToMemberDeclDefMatch) {
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,7 +395,7 @@ 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);
@ -407,7 +409,7 @@ TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) {
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,7 +423,7 @@ 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);
@ -435,7 +437,7 @@ TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) {
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,7 +465,7 @@ 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);
@ -475,7 +477,7 @@ TEST(DIEHashTest, RefUnnamedType) {
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);
@ -573,11 +575,11 @@ TEST(DIEHashTest, MemberSdata) {
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);
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);
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);
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);
@ -644,7 +646,7 @@ TEST(DIEHashTest, MemberBlock) {
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);