llvm.org GIT mirror llvm / 12d5224
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 David Blaikie 6 years ago
6 changed file(s) with 107 addition(s) and 101 deletion(s). Raw diff Collapse all Expand all
171171
172172 /// addChild - Add a child to the DIE.
173173 ///
174 void addChild(DIE *Child) {
174 void addChild(std::unique_ptr Child) {
175175 assert(!Child->getParent());
176176 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
177 Children.push_back(std::unique_ptr(Child));
178177 Child->Parent = this;
178 Children.push_back(std::move(Child));
179179 }
180180
181181 /// findAttribute - Find a value in the DIE with the attribute given,
505505 return ScopeDIE;
506506 }
507507
508 DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit &TheCU,
509 LexicalScope *Scope,
510 SmallVectorImpl &Children) {
508 DIE *DwarfDebug::createScopeChildrenDIE(
509 DwarfCompileUnit &TheCU, LexicalScope *Scope,
510 SmallVectorImpl> &Children) {
511511 DIE *ObjectPointer = nullptr;
512512
513513 // Collect arguments for current function.
514514 if (LScopes.isCurrentFunctionScope(Scope)) {
515515 for (DbgVariable *ArgDV : CurrentFnArguments)
516 if (ArgDV)
517 if (DIE *Arg =
518 TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope())) {
519 Children.push_back(Arg);
520 if (ArgDV->isObjectPointer())
521 ObjectPointer = Arg;
522 }
516 if (ArgDV) {
517 std::unique_ptr Arg =
518 TheCU.constructVariableDIE(*ArgDV, Scope->isAbstractScope());
519 assert(Arg);
520 if (ArgDV->isObjectPointer())
521 ObjectPointer = Arg.get();
522 Children.push_back(std::move(Arg));
523 }
523524
524525 // If this is a variadic function, add an unspecified parameter.
525526 DISubprogram SP(Scope->getScopeNode());
526527 DIArray FnArgs = SP.getType().getTypeArray();
527528 if (FnArgs.getElement(FnArgs.getNumElements() - 1)
528529 .isUnspecifiedParameter()) {
529 DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);
530 Children.push_back(Ellipsis);
530 Children.push_back(
531 make_unique(dwarf::DW_TAG_unspecified_parameters));
531532 }
532533 }
533534
534535 // Collect lexical scope children first.
535 for (DbgVariable *DV : ScopeVariables.lookup(Scope))
536 if (DIE *Variable =
537 TheCU.constructVariableDIE(*DV, Scope->isAbstractScope())) {
538 Children.push_back(Variable);
539 if (DV->isObjectPointer())
540 ObjectPointer = Variable;
541 }
536 for (DbgVariable *DV : ScopeVariables.lookup(Scope)) {
537 std::unique_ptr Variable =
538 TheCU.constructVariableDIE(*DV, Scope->isAbstractScope());
539 assert(Variable);
540 Children.push_back(std::move(Variable));
541 if (DV->isObjectPointer())
542 ObjectPointer = Variable.get();
543 }
542544 for (LexicalScope *LS : Scope->getChildren())
543545 if (DIE *Nested = constructScopeDIE(TheCU, LS))
544 Children.push_back(Nested);
546 Children.push_back(std::unique_ptr(Nested));
545547 return ObjectPointer;
546548 }
547549
553555
554556 DIScope DS(Scope->getScopeNode());
555557
556 SmallVector<DIE *, 8> Children;
558 SmallVector<std::unique_ptr, 8> Children;
557559 DIE *ObjectPointer = nullptr;
558560 bool ChildrenCreated = false;
559561
609611 ObjectPointer = createScopeChildrenDIE(TheCU, Scope, Children);
610612
611613 // Add children
612 for (DIE *I : Children)
613 ScopeDIE->addChild(I);
614 for (auto &I : Children)
615 ScopeDIE->addChild(std::move(I));
614616
615617 if (DS.isSubprogram() && ObjectPointer != nullptr)
616618 TheCU.addDIEEntry(*ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
861863 if (!DV.isVariable())
862864 continue;
863865 DbgVariable NewVar(DV, nullptr, this);
864 if (DIE *VariableDIE = SPCU->constructVariableDIE(NewVar, false))
865 SPDIE->addChild(VariableDIE);
866 SPDIE->addChild(SPCU->constructVariableDIE(NewVar, false));
866867 }
867868 }
868869 }
366366 DIE *constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope);
367367 /// A helper function to create children of a Scope DIE.
368368 DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
369 SmallVectorImpl<DIE *> &Children);
369 SmallVectorImpl<std::unique_ptr> &Children);
370370
371371 /// \brief Emit initial Dwarf sections with a label at the start of each one.
372372 void emitSectionLabels();
382382 DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, DIDescriptor N) {
383383 assert(Tag != dwarf::DW_TAG_auto_variable &&
384384 Tag != dwarf::DW_TAG_arg_variable);
385 Parent.addChild(new DIE((dwarf::Tag)Tag));
385 Parent.addChild(make_unique((dwarf::Tag)Tag));
386386 DIE &Die = *Parent.getChildren().back();
387387 if (N)
388388 insertDIE(N, &Die);
17921792 }
17931793
17941794 /// constructVariableDIE - Construct a DIE for the given DbgVariable.
1795 DIE *DwarfUnit::constructVariableDIE(DbgVariable &DV, bool isScopeAbstract) {
1795 std::unique_ptr DwarfUnit::constructVariableDIE(DbgVariable &DV,
1796 bool isScopeAbstract) {
17961797 auto D = constructVariableDIEImpl(DV, isScopeAbstract);
17971798 DV.setDIE(*D);
17981799 return D;
17991800 }
18001801
1801 DIE *DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
1802 bool isScopeAbstract) {
1802 std::unique_ptr DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
1803 bool isScopeAbstract) {
18031804 StringRef Name = DV.getName();
18041805
18051806 // Define variable debug information entry.
1806 DIE *VariableDie = new DIE(DV.getTag());
1807 auto VariableDie = make_unique(DV.getTag());
18071808 DbgVariable *AbsVar = DV.getAbstractVariable();
18081809 DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : nullptr;
18091810 if (AbsDIE)
269269
270270 /// addDie - Adds or interns the DIE to the compile unit.
271271 ///
272 void addDie(DIE *Buffer) { UnitDie->addChild(Buffer); }
272 void addDie(DIE *Buffer) { UnitDie->addChild(std::unique_ptr(Buffer)); }
273273
274274 /// addFlag - Add a flag that is true to the DIE.
275275 void addFlag(DIE &Die, dwarf::Attribute Attribute);
424424 void constructContainingTypeDIEs();
425425
426426 /// constructVariableDIE - Construct a DIE for the given DbgVariable.
427 DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
427 std::unique_ptr constructVariableDIE(DbgVariable &DV,
428 bool isScopeAbstract);
428429
429430 /// constructSubprogramArguments - Construct function argument DIEs.
430431 void constructSubprogramArguments(DIE &Buffer, DIArray Args);
458459 private:
459460 /// \brief Construct a DIE for the given DbgVariable without initializing the
460461 /// DbgVariable's DIE reference.
461 DIE *constructVariableDIEImpl(const DbgVariable &DV, bool isScopeAbstract);
462 std::unique_ptr constructVariableDIEImpl(const DbgVariable &DV,
463 bool isScopeAbstract);
462464
463465 /// constructTypeDIE - Construct basic type die from DIBasicType.
464466 void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
1111 #include "llvm/Support/Debug.h"
1212 #include "llvm/Support/Dwarf.h"
1313 #include "llvm/Support/Format.h"
14 #include "llvm/ADT/STLExtras.h"
1415 #include "gtest/gtest.h"
1516
1617 using namespace llvm;
5859 TEST(DIEHashTest, NamespacedType) {
5960 DIE CU(dwarf::DW_TAG_compile_unit);
6061
61 DIE *Space = new DIE(dwarf::DW_TAG_namespace);
62 auto Space = make_unique(dwarf::DW_TAG_namespace);
6263 DIEInteger One(1);
6364 DIEString SpaceStr(&One, "space");
6465 Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &SpaceStr);
6667 Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
6768 // sibling?
6869
69 DIE *Foo = new DIE(dwarf::DW_TAG_structure_type);
70 auto Foo = make_unique(dwarf::DW_TAG_structure_type);
7071 DIEString FooStr(&One, "foo");
7172 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
7273 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
7374
74 Space->addChild(Foo);
75 CU.addChild(Space);
76
77 uint64_t MD5Res = DIEHash().computeTypeSignature(*Foo);
75 DIE &N = *Foo;
76 Space->addChild(std::move(Foo));
77 CU.addChild(std::move(Space));
78
79 uint64_t MD5Res = DIEHash().computeTypeSignature(N);
7880
7981 // The exact same hash GCC produces for this DIE.
8082 ASSERT_EQ(0x7b80381fd17f1e33ULL, MD5Res);
8587 DIE Unnamed(dwarf::DW_TAG_structure_type);
8688 DIEInteger Four(4);
8789 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
88
89 DIE *Member = new DIE(dwarf::DW_TAG_member);
90 DIEString MemberStr(&Four, "member");
91 Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr);
92 DIEInteger Zero(0);
93 Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
94 &Zero);
95
96 Unnamed.addChild(Member);
9790
9891 DIE Int(dwarf::DW_TAG_base_type);
9992 DIEString IntStr(&Four, "int");
10396 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
10497
10598 DIEEntry IntRef(Int);
99
100 auto Member = make_unique(dwarf::DW_TAG_member);
101 DIEString MemberStr(&Four, "member");
102 Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr);
103 DIEInteger Zero(0);
104 Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
105 &Zero);
106106 Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
107
108 Unnamed.addChild(std::move(Member));
107109
108110 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
109111
116118 DIEInteger Eight(8);
117119 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
118120
119 DIE *Mem1 = new DIE(dwarf::DW_TAG_member);
120121 DIEInteger Four(4);
121 DIEString Mem1Str(&Four, "mem1");
122 Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem1Str);
123 DIEInteger Zero(0);
124 Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
125 &Zero);
126
127 Unnamed.addChild(Mem1);
128
129 DIE *Mem2 = new DIE(dwarf::DW_TAG_member);
130 DIEString Mem2Str(&Four, "mem2");
131 Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem2Str);
132 Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
133 &Four);
134
135 Unnamed.addChild(Mem2);
136
137122 DIE Int(dwarf::DW_TAG_base_type);
138123 DIEString IntStr(&Four, "int");
139124 Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr);
142127 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
143128
144129 DIEEntry IntRef(Int);
130
131 auto Mem1 = make_unique(dwarf::DW_TAG_member);
132 DIEString Mem1Str(&Four, "mem1");
133 Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem1Str);
134 DIEInteger Zero(0);
135 Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
136 &Zero);
145137 Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
138
139 Unnamed.addChild(std::move(Mem1));
140
141 auto Mem2 = make_unique(dwarf::DW_TAG_member);
142 DIEString Mem2Str(&Four, "mem2");
143 Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem2Str);
144 Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
145 &Four);
146146 Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
147
148 Unnamed.addChild(std::move(Mem2));
147149
148150 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
149151
158160 DIEString FooStr(&One, "foo");
159161 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
160162
161 DIE *Mem = new DIE(dwarf::DW_TAG_member);
163 auto Mem = make_unique(dwarf::DW_TAG_member);
162164 DIEString MemStr(&One, "mem");
163165 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
164166 DIEEntry FooRef(Foo);
165167 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
166168 // DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
167169
168 Foo.addChild(Mem);
170 Foo.addChild(std::move(Mem));
169171
170172 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
171173
180182 DIEString FooStr(&Eight, "foo");
181183 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
182184
183 DIE *Mem = new DIE(dwarf::DW_TAG_member);
185 auto Mem = make_unique(dwarf::DW_TAG_member);
184186 DIEString MemStr(&Eight, "mem");
185187 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
186188 DIEInteger Zero(0);
194196 DIEEntry FooPtrRef(FooPtr);
195197 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooPtrRef);
196198
197 Foo.addChild(Mem);
199 Foo.addChild(std::move(Mem));
198200
199201 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
200202
209211 DIEString FooStr(&Eight, "foo");
210212 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
211213
212 DIE *Mem = new DIE(dwarf::DW_TAG_member);
214 auto Mem = make_unique(dwarf::DW_TAG_member);
213215 DIEString MemStr(&Eight, "mem");
214216 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
215217 DIEInteger Zero(0);
227229 DIEEntry FooRefConstRef(FooRefConst);
228230 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
229231
230 Foo.addChild(Mem);
232 Foo.addChild(std::move(Mem));
231233
232234 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
233235
242244 DIEString FooStr(&Eight, "foo");
243245 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
244246
245 DIE *Mem = new DIE(dwarf::DW_TAG_member);
247 auto Mem = make_unique(dwarf::DW_TAG_member);
246248 DIEString MemStr(&Eight, "mem");
247249 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
248250 DIEInteger Zero(0);
260262 DIEEntry FooRefConstRef(FooRefConst);
261263 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
262264
263 Foo.addChild(Mem);
265 Foo.addChild(std::move(Mem));
264266
265267 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
266268
275277 DIEString FooStr(&Eight, "foo");
276278 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
277279
278 DIE *Mem = new DIE(dwarf::DW_TAG_member);
280 auto Mem = make_unique(dwarf::DW_TAG_member);
279281 DIEString MemStr(&Eight, "mem");
280282 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
281283 DIEInteger Zero(0);
290292 DIEEntry PtrToFooMemRef(PtrToFooMem);
291293 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
292294
293 Foo.addChild(Mem);
295 Foo.addChild(std::move(Mem));
294296
295297 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
296298
319321 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
320322 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
321323
322 DIE *Mem = new DIE(dwarf::DW_TAG_member);
324 auto Mem = make_unique(dwarf::DW_TAG_member);
323325 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
324326 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
325327 &Zero);
334336 DIEEntry PtrToFooMemRef(PtrToFooMem);
335337 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
336338
337 Foo.addChild(Mem);
339 Foo.addChild(std::move(Mem));
338340
339341 MD5ResDecl = DIEHash().computeTypeSignature(Foo);
340342 }
348350 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
349351 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
350352
351 DIE *Mem = new DIE(dwarf::DW_TAG_member);
353 auto Mem = make_unique(dwarf::DW_TAG_member);
352354 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
353355 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
354356 &Zero);
363365 DIEEntry PtrToFooMemRef(PtrToFooMem);
364366 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
365367
366 Foo.addChild(Mem);
368 Foo.addChild(std::move(Mem));
367369
368370 MD5ResDef = DIEHash().computeTypeSignature(Foo);
369371 }
392394 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
393395 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
394396
395 DIE *Mem = new DIE(dwarf::DW_TAG_member);
397 auto Mem = make_unique(dwarf::DW_TAG_member);
396398 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
397399 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
398400 &Zero);
406408 DIEEntry PtrToFooMemRef(PtrToFooMem);
407409 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
408410
409 Foo.addChild(Mem);
411 Foo.addChild(std::move(Mem));
410412
411413 MD5ResDecl = DIEHash().computeTypeSignature(Foo);
412414 }
420422 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
421423 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
422424
423 DIE *Mem = new DIE(dwarf::DW_TAG_member);
425 auto Mem = make_unique(dwarf::DW_TAG_member);
424426 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
425427 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
426428 &Zero);
434436 DIEEntry PtrToFooMemRef(PtrToFooMem);
435437 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
436438
437 Foo.addChild(Mem);
439 Foo.addChild(std::move(Mem));
438440
439441 MD5ResDef = DIEHash().computeTypeSignature(Foo);
440442 }
462464 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
463465 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
464466
465 DIE *Mem = new DIE(dwarf::DW_TAG_member);
467 auto Mem = make_unique(dwarf::DW_TAG_member);
466468 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
467469 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
468470
474476 DIEEntry UnnamedPtrRef(UnnamedPtr);
475477 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef);
476478
477 Foo.addChild(Mem);
479 Foo.addChild(std::move(Mem));
478480
479481 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
480482
487489 DIEInteger One(1);
488490 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
489491
490 DIE *Foo = new DIE(dwarf::DW_TAG_structure_type);
492 auto Foo = make_unique(dwarf::DW_TAG_structure_type);
491493 DIEString FooStr(&One, "foo");
492494 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
493495 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
494496
495 Unnamed.addChild(Foo);
497 Unnamed.addChild(std::move(Foo));
496498
497499 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
498500
506508 DIEInteger One(1);
507509 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
508510
509 DIE *Func = new DIE(dwarf::DW_TAG_subprogram);
511 auto Func = make_unique(dwarf::DW_TAG_subprogram);
510512 DIEString FuncStr(&One, "func");
511513 Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr);
512514
513 Unnamed.addChild(Func);
515 Unnamed.addChild(std::move(Func));
514516
515517 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
516518
530532 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
531533 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
532534
533 DIE *Func = new DIE(dwarf::DW_TAG_subprogram);
535 auto Func = make_unique(dwarf::DW_TAG_subprogram);
534536 DIEString FuncStr(&One, "func");
535537 DIEString FuncLinkage(&One, "_ZN1A4funcEv");
536538 DIEInteger Two(2);
541543 Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, &FuncLinkage);
542544 Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
543545
544 A.addChild(Func);
546 A.addChild(std::move(Func));
545547
546548 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
547549
572574 IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
573575
574576 DIEEntry IntTy(IntTyDIE);
575 DIE *PITyDIE = new DIE(dwarf::DW_TAG_const_type);
577 auto PITyDIE = make_unique(dwarf::DW_TAG_const_type);
576578 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntTy);
577579
578580 DIEEntry PITy(*PITyDIE);
579 DIE *PI = new DIE(dwarf::DW_TAG_member);
581 auto PI = make_unique(dwarf::DW_TAG_member);
580582 DIEString PIStr(&One, "PI");
581583 DIEInteger Two(2);
582584 DIEInteger NegThree(-3);
588590 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
589591 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, &NegThree);
590592
591 A.addChild(PI);
593 A.addChild(std::move(PI));
592594
593595 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
594596 ASSERT_EQ(0x9a216000dd3788a7ULL, MD5Res);
610612
611613 DIEInteger Four(4);
612614 DIEString FStr(&One, "float");
613 DIE *FloatTyDIE = new DIE(dwarf::DW_TAG_base_type);
615 auto FloatTyDIE = make_unique(dwarf::DW_TAG_base_type);
614616 FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
615617 FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Four);
616618 FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
617619
618620 DIEEntry FloatTy(*FloatTyDIE);
619 DIE *PITyDIE = new DIE(dwarf::DW_TAG_const_type);
621 auto PITyDIE = make_unique(dwarf::DW_TAG_const_type);
620622 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FloatTy);
621623
622624 DIEEntry PITy(*PITyDIE);
623 DIE *PI = new DIE(dwarf::DW_TAG_member);
625 auto PI = make_unique(dwarf::DW_TAG_member);
624626 DIEString PIStr(&One, "PI");
625627 DIEInteger Two(2);
626628 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
643645
644646 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
645647
646 A.addChild(PI);
648 A.addChild(std::move(PI));
647649
648650 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
649651 ASSERT_EQ(0x493af53ad3d3f651ULL, MD5Res);