blob: 04c5a8ac01997dc894f7888c9b88495d2e1669e8 [file] [log] [blame]
Eric Christopher25b7adc2013-09-03 21:57:57 +00001//===- llvm/unittest/DebugInfo/DWARFFormValueTest.cpp ---------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "../lib/CodeGen/AsmPrinter/DIE.h"
11#include "../lib/CodeGen/AsmPrinter/DIEHash.h"
Eric Christopher25b7adc2013-09-03 21:57:57 +000012#include "llvm/Support/Debug.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000013#include "llvm/Support/Dwarf.h"
Eric Christopher25b7adc2013-09-03 21:57:57 +000014#include "llvm/Support/Format.h"
David Blaikie914046e2014-04-25 20:00:34 +000015#include "llvm/ADT/STLExtras.h"
Eric Christopher25b7adc2013-09-03 21:57:57 +000016#include "gtest/gtest.h"
17
Eric Christopher25b7adc2013-09-03 21:57:57 +000018using namespace llvm;
David Blaikie59804192013-10-15 23:00:17 +000019
20namespace {
David Blaikie6a7a4462013-10-21 20:28:30 +000021TEST(DIEHashTest, Data1) {
Eric Christopher25b7adc2013-09-03 21:57:57 +000022 DIEHash Hash;
Benjamin Kramer0f01d4e2013-09-29 11:29:20 +000023 DIE Die(dwarf::DW_TAG_base_type);
24 DIEInteger Size(4);
25 Die.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Size);
David Blaikie2aee7be2013-10-24 18:29:03 +000026 uint64_t MD5Res = Hash.computeTypeSignature(Die);
David Blaikie6316ca42013-10-16 23:36:20 +000027 ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
28}
29
David Blaikie6cf58c82013-10-21 22:36:50 +000030// struct {};
David Blaikie6a7a4462013-10-21 20:28:30 +000031TEST(DIEHashTest, TrivialType) {
David Blaikie8a142aa2013-10-17 00:10:34 +000032 DIE Unnamed(dwarf::DW_TAG_structure_type);
David Blaikie6316ca42013-10-16 23:36:20 +000033 DIEInteger One(1);
David Blaikie8a142aa2013-10-17 00:10:34 +000034 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
David Blaikie6316ca42013-10-16 23:36:20 +000035
36 // Line and file number are ignored.
David Blaikie8a142aa2013-10-17 00:10:34 +000037 Unnamed.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
38 Unnamed.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
David Blaikie2aee7be2013-10-24 18:29:03 +000039 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
David Blaikie6316ca42013-10-16 23:36:20 +000040
41 // The exact same hash GCC produces for this DIE.
42 ASSERT_EQ(0x715305ce6cfd9ad1ULL, MD5Res);
Eric Christopher25b7adc2013-09-03 21:57:57 +000043}
David Blaikie8a142aa2013-10-17 00:10:34 +000044
David Blaikie6cf58c82013-10-21 22:36:50 +000045// struct foo { };
David Blaikie6a7a4462013-10-21 20:28:30 +000046TEST(DIEHashTest, NamedType) {
David Blaikie8a142aa2013-10-17 00:10:34 +000047 DIE Foo(dwarf::DW_TAG_structure_type);
48 DIEInteger One(1);
49 DIEString FooStr(&One, "foo");
50 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
51 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
52
David Blaikie2aee7be2013-10-24 18:29:03 +000053 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikie8a142aa2013-10-17 00:10:34 +000054
55 // The exact same hash GCC produces for this DIE.
56 ASSERT_EQ(0xd566dbd2ca5265ffULL, MD5Res);
57}
58
David Blaikie6cf58c82013-10-21 22:36:50 +000059// namespace space { struct foo { }; }
David Blaikie6a7a4462013-10-21 20:28:30 +000060TEST(DIEHashTest, NamespacedType) {
David Blaikie8a142aa2013-10-17 00:10:34 +000061 DIE CU(dwarf::DW_TAG_compile_unit);
62
David Blaikie914046e2014-04-25 20:00:34 +000063 auto Space = make_unique<DIE>(dwarf::DW_TAG_namespace);
David Blaikie8a142aa2013-10-17 00:10:34 +000064 DIEInteger One(1);
65 DIEString SpaceStr(&One, "space");
66 Space->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &SpaceStr);
67 // DW_AT_declaration is ignored.
68 Space->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
69 // sibling?
70
David Blaikie914046e2014-04-25 20:00:34 +000071 auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
David Blaikie8a142aa2013-10-17 00:10:34 +000072 DIEString FooStr(&One, "foo");
73 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
74 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
75
David Blaikie914046e2014-04-25 20:00:34 +000076 DIE &N = *Foo;
77 Space->addChild(std::move(Foo));
78 CU.addChild(std::move(Space));
David Blaikie8a142aa2013-10-17 00:10:34 +000079
David Blaikie914046e2014-04-25 20:00:34 +000080 uint64_t MD5Res = DIEHash().computeTypeSignature(N);
David Blaikie8a142aa2013-10-17 00:10:34 +000081
82 // The exact same hash GCC produces for this DIE.
83 ASSERT_EQ(0x7b80381fd17f1e33ULL, MD5Res);
84}
David Blaikieca353be2013-10-17 22:07:09 +000085
David Blaikie6cf58c82013-10-21 22:36:50 +000086// struct { int member; };
David Blaikie6a7a4462013-10-21 20:28:30 +000087TEST(DIEHashTest, TypeWithMember) {
David Blaikieca353be2013-10-17 22:07:09 +000088 DIE Unnamed(dwarf::DW_TAG_structure_type);
89 DIEInteger Four(4);
90 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
91
David Blaikieca353be2013-10-17 22:07:09 +000092 DIE Int(dwarf::DW_TAG_base_type);
93 DIEString IntStr(&Four, "int");
94 Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr);
95 Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
96 DIEInteger Five(5);
97 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
98
David Blaikie8dbcc3f2014-04-25 19:33:43 +000099 DIEEntry IntRef(Int);
David Blaikie914046e2014-04-25 20:00:34 +0000100
101 auto Member = make_unique<DIE>(dwarf::DW_TAG_member);
102 DIEString MemberStr(&Four, "member");
103 Member->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemberStr);
104 DIEInteger Zero(0);
105 Member->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
106 &Zero);
David Blaikieca353be2013-10-17 22:07:09 +0000107 Member->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
108
David Blaikie914046e2014-04-25 20:00:34 +0000109 Unnamed.addChild(std::move(Member));
110
David Blaikie2aee7be2013-10-24 18:29:03 +0000111 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
David Blaikieca353be2013-10-17 22:07:09 +0000112
113 ASSERT_EQ(0x5646aa436b7e07c6ULL, MD5Res);
114}
David Blaikie980d4992013-10-21 18:59:40 +0000115
David Blaikie6cf58c82013-10-21 22:36:50 +0000116// struct foo { int mem1, mem2; };
David Blaikie6a7a4462013-10-21 20:28:30 +0000117TEST(DIEHashTest, ReusedType) {
David Blaikie980d4992013-10-21 18:59:40 +0000118 DIE Unnamed(dwarf::DW_TAG_structure_type);
119 DIEInteger Eight(8);
120 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
121
David Blaikie980d4992013-10-21 18:59:40 +0000122 DIEInteger Four(4);
David Blaikie980d4992013-10-21 18:59:40 +0000123 DIE Int(dwarf::DW_TAG_base_type);
124 DIEString IntStr(&Four, "int");
125 Int.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &IntStr);
126 Int.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
127 DIEInteger Five(5);
128 Int.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
129
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000130 DIEEntry IntRef(Int);
David Blaikie914046e2014-04-25 20:00:34 +0000131
132 auto Mem1 = make_unique<DIE>(dwarf::DW_TAG_member);
133 DIEString Mem1Str(&Four, "mem1");
134 Mem1->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem1Str);
135 DIEInteger Zero(0);
136 Mem1->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
137 &Zero);
David Blaikie980d4992013-10-21 18:59:40 +0000138 Mem1->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
David Blaikie914046e2014-04-25 20:00:34 +0000139
140 Unnamed.addChild(std::move(Mem1));
141
142 auto Mem2 = make_unique<DIE>(dwarf::DW_TAG_member);
143 DIEString Mem2Str(&Four, "mem2");
144 Mem2->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &Mem2Str);
145 Mem2->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
146 &Four);
David Blaikie980d4992013-10-21 18:59:40 +0000147 Mem2->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntRef);
148
David Blaikie914046e2014-04-25 20:00:34 +0000149 Unnamed.addChild(std::move(Mem2));
150
David Blaikie2aee7be2013-10-24 18:29:03 +0000151 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
David Blaikie980d4992013-10-21 18:59:40 +0000152
153 ASSERT_EQ(0x3a7dc3ed7b76b2f8ULL, MD5Res);
154}
155
David Blaikie6cf58c82013-10-21 22:36:50 +0000156// struct foo { static foo f; };
David Blaikie6a7a4462013-10-21 20:28:30 +0000157TEST(DIEHashTest, RecursiveType) {
David Blaikie980d4992013-10-21 18:59:40 +0000158 DIE Foo(dwarf::DW_TAG_structure_type);
159 DIEInteger One(1);
160 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
161 DIEString FooStr(&One, "foo");
162 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
163
David Blaikie914046e2014-04-25 20:00:34 +0000164 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikie980d4992013-10-21 18:59:40 +0000165 DIEString MemStr(&One, "mem");
166 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000167 DIEEntry FooRef(Foo);
David Blaikie980d4992013-10-21 18:59:40 +0000168 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
169 // DW_AT_external and DW_AT_declaration are ignored anyway, so skip them.
170
David Blaikie914046e2014-04-25 20:00:34 +0000171 Foo.addChild(std::move(Mem));
David Blaikie980d4992013-10-21 18:59:40 +0000172
David Blaikie2aee7be2013-10-24 18:29:03 +0000173 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikie980d4992013-10-21 18:59:40 +0000174
175 ASSERT_EQ(0x73d8b25aef227b06ULL, MD5Res);
176}
David Blaikie6cf58c82013-10-21 22:36:50 +0000177
178// struct foo { foo *mem; };
179TEST(DIEHashTest, Pointer) {
180 DIE Foo(dwarf::DW_TAG_structure_type);
181 DIEInteger Eight(8);
182 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
183 DIEString FooStr(&Eight, "foo");
184 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
185
David Blaikie914046e2014-04-25 20:00:34 +0000186 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikie6cf58c82013-10-21 22:36:50 +0000187 DIEString MemStr(&Eight, "mem");
188 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
189 DIEInteger Zero(0);
190 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
191
192 DIE FooPtr(dwarf::DW_TAG_pointer_type);
193 FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000194 DIEEntry FooRef(Foo);
David Blaikie6cf58c82013-10-21 22:36:50 +0000195 FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
196
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000197 DIEEntry FooPtrRef(FooPtr);
David Blaikie6cf58c82013-10-21 22:36:50 +0000198 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooPtrRef);
199
David Blaikie914046e2014-04-25 20:00:34 +0000200 Foo.addChild(std::move(Mem));
David Blaikie6cf58c82013-10-21 22:36:50 +0000201
David Blaikie2aee7be2013-10-24 18:29:03 +0000202 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikie6cf58c82013-10-21 22:36:50 +0000203
204 ASSERT_EQ(0x74ea73862e8708d2ULL, MD5Res);
205}
David Blaikiefe3233a2013-10-21 23:06:19 +0000206
207// struct foo { foo &mem; };
208TEST(DIEHashTest, Reference) {
209 DIE Foo(dwarf::DW_TAG_structure_type);
210 DIEInteger Eight(8);
211 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
212 DIEString FooStr(&Eight, "foo");
213 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
214
David Blaikie914046e2014-04-25 20:00:34 +0000215 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikiefe3233a2013-10-21 23:06:19 +0000216 DIEString MemStr(&Eight, "mem");
217 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
218 DIEInteger Zero(0);
219 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
220
221 DIE FooRef(dwarf::DW_TAG_reference_type);
222 FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000223 DIEEntry FooEntry(Foo);
David Blaikiefe3233a2013-10-21 23:06:19 +0000224 FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
225
226 DIE FooRefConst(dwarf::DW_TAG_const_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000227 DIEEntry FooRefRef(FooRef);
David Blaikiefe3233a2013-10-21 23:06:19 +0000228 FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef);
229
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000230 DIEEntry FooRefConstRef(FooRefConst);
David Blaikiefe3233a2013-10-21 23:06:19 +0000231 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
232
David Blaikie914046e2014-04-25 20:00:34 +0000233 Foo.addChild(std::move(Mem));
David Blaikiefe3233a2013-10-21 23:06:19 +0000234
David Blaikie2aee7be2013-10-24 18:29:03 +0000235 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikiefe3233a2013-10-21 23:06:19 +0000236
237 ASSERT_EQ(0xa0b15f467ad4525bULL, MD5Res);
238}
239
240// struct foo { foo &&mem; };
241TEST(DIEHashTest, RValueReference) {
242 DIE Foo(dwarf::DW_TAG_structure_type);
243 DIEInteger Eight(8);
244 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
245 DIEString FooStr(&Eight, "foo");
246 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
247
David Blaikie914046e2014-04-25 20:00:34 +0000248 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikiefe3233a2013-10-21 23:06:19 +0000249 DIEString MemStr(&Eight, "mem");
250 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
251 DIEInteger Zero(0);
252 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
253
254 DIE FooRef(dwarf::DW_TAG_rvalue_reference_type);
255 FooRef.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000256 DIEEntry FooEntry(Foo);
David Blaikiefe3233a2013-10-21 23:06:19 +0000257 FooRef.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
258
259 DIE FooRefConst(dwarf::DW_TAG_const_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000260 DIEEntry FooRefRef(FooRef);
David Blaikiefe3233a2013-10-21 23:06:19 +0000261 FooRefConst.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefRef);
262
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000263 DIEEntry FooRefConstRef(FooRefConst);
David Blaikiefe3233a2013-10-21 23:06:19 +0000264 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRefConstRef);
265
David Blaikie914046e2014-04-25 20:00:34 +0000266 Foo.addChild(std::move(Mem));
David Blaikiefe3233a2013-10-21 23:06:19 +0000267
David Blaikie2aee7be2013-10-24 18:29:03 +0000268 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikiefe3233a2013-10-21 23:06:19 +0000269
270 ASSERT_EQ(0xad211c8c3b31e57ULL, MD5Res);
271}
David Blaikied70a0552013-10-22 18:14:41 +0000272
273// struct foo { foo foo::*mem; };
274TEST(DIEHashTest, PtrToMember) {
275 DIE Foo(dwarf::DW_TAG_structure_type);
276 DIEInteger Eight(8);
277 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
278 DIEString FooStr(&Eight, "foo");
279 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
280
David Blaikie914046e2014-04-25 20:00:34 +0000281 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikied70a0552013-10-22 18:14:41 +0000282 DIEString MemStr(&Eight, "mem");
283 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
284 DIEInteger Zero(0);
285 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
286
287 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000288 DIEEntry FooEntry(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000289 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooEntry);
Eric Christopherda1d7d92014-02-20 00:54:38 +0000290 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
291 &FooEntry);
David Blaikied70a0552013-10-22 18:14:41 +0000292
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000293 DIEEntry PtrToFooMemRef(PtrToFooMem);
David Blaikied70a0552013-10-22 18:14:41 +0000294 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
295
David Blaikie914046e2014-04-25 20:00:34 +0000296 Foo.addChild(std::move(Mem));
David Blaikied70a0552013-10-22 18:14:41 +0000297
David Blaikie2aee7be2013-10-24 18:29:03 +0000298 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000299
300 ASSERT_EQ(0x852e0c9ff7c04ebULL, MD5Res);
301}
302
303// Check that the hash for a pointer-to-member matches regardless of whether the
304// pointed-to type is a declaration or a definition.
305//
306// struct bar; // { };
307// struct foo { bar foo::*mem; };
308TEST(DIEHashTest, PtrToMemberDeclDefMatch) {
309 DIEInteger Zero(0);
310 DIEInteger One(1);
311 DIEInteger Eight(8);
312 DIEString FooStr(&Eight, "foo");
313 DIEString BarStr(&Eight, "bar");
314 DIEString MemStr(&Eight, "mem");
315 uint64_t MD5ResDecl;
316 {
317 DIE Bar(dwarf::DW_TAG_structure_type);
318 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
319 Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
320
321 DIE Foo(dwarf::DW_TAG_structure_type);
322 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
323 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
324
David Blaikie914046e2014-04-25 20:00:34 +0000325 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikied70a0552013-10-22 18:14:41 +0000326 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
327 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
328 &Zero);
329
330 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000331 DIEEntry BarEntry(Bar);
David Blaikied70a0552013-10-22 18:14:41 +0000332 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000333 DIEEntry FooEntry(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000334 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
335 &FooEntry);
336
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000337 DIEEntry PtrToFooMemRef(PtrToFooMem);
David Blaikied70a0552013-10-22 18:14:41 +0000338 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
339
David Blaikie914046e2014-04-25 20:00:34 +0000340 Foo.addChild(std::move(Mem));
David Blaikied70a0552013-10-22 18:14:41 +0000341
David Blaikie2aee7be2013-10-24 18:29:03 +0000342 MD5ResDecl = DIEHash().computeTypeSignature(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000343 }
344 uint64_t MD5ResDef;
345 {
346 DIE Bar(dwarf::DW_TAG_structure_type);
347 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
348 Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
349
350 DIE Foo(dwarf::DW_TAG_structure_type);
351 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
352 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
353
David Blaikie914046e2014-04-25 20:00:34 +0000354 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikied70a0552013-10-22 18:14:41 +0000355 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
356 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
357 &Zero);
358
359 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000360 DIEEntry BarEntry(Bar);
David Blaikied70a0552013-10-22 18:14:41 +0000361 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000362 DIEEntry FooEntry(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000363 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
364 &FooEntry);
365
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000366 DIEEntry PtrToFooMemRef(PtrToFooMem);
David Blaikied70a0552013-10-22 18:14:41 +0000367 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
368
David Blaikie914046e2014-04-25 20:00:34 +0000369 Foo.addChild(std::move(Mem));
David Blaikied70a0552013-10-22 18:14:41 +0000370
David Blaikie2aee7be2013-10-24 18:29:03 +0000371 MD5ResDef = DIEHash().computeTypeSignature(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000372 }
373 ASSERT_EQ(MD5ResDef, MD5ResDecl);
374}
375
376// Check that the hash for a pointer-to-member matches regardless of whether the
377// pointed-to type is a declaration or a definition.
378//
379// struct bar; // { };
380// struct foo { bar bar::*mem; };
381TEST(DIEHashTest, PtrToMemberDeclDefMisMatch) {
382 DIEInteger Zero(0);
383 DIEInteger One(1);
384 DIEInteger Eight(8);
385 DIEString FooStr(&Eight, "foo");
386 DIEString BarStr(&Eight, "bar");
387 DIEString MemStr(&Eight, "mem");
388 uint64_t MD5ResDecl;
389 {
390 DIE Bar(dwarf::DW_TAG_structure_type);
391 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
392 Bar.addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
393
394 DIE Foo(dwarf::DW_TAG_structure_type);
395 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
396 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
397
David Blaikie914046e2014-04-25 20:00:34 +0000398 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikied70a0552013-10-22 18:14:41 +0000399 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
400 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
401 &Zero);
402
403 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000404 DIEEntry BarEntry(Bar);
David Blaikied70a0552013-10-22 18:14:41 +0000405 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
406 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
407 &BarEntry);
408
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000409 DIEEntry PtrToFooMemRef(PtrToFooMem);
David Blaikied70a0552013-10-22 18:14:41 +0000410 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
411
David Blaikie914046e2014-04-25 20:00:34 +0000412 Foo.addChild(std::move(Mem));
David Blaikied70a0552013-10-22 18:14:41 +0000413
David Blaikie2aee7be2013-10-24 18:29:03 +0000414 MD5ResDecl = DIEHash().computeTypeSignature(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000415 }
416 uint64_t MD5ResDef;
417 {
418 DIE Bar(dwarf::DW_TAG_structure_type);
419 Bar.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &BarStr);
420 Bar.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
421
422 DIE Foo(dwarf::DW_TAG_structure_type);
423 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
424 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
425
David Blaikie914046e2014-04-25 20:00:34 +0000426 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikied70a0552013-10-22 18:14:41 +0000427 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
428 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1,
429 &Zero);
430
431 DIE PtrToFooMem(dwarf::DW_TAG_ptr_to_member_type);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000432 DIEEntry BarEntry(Bar);
David Blaikied70a0552013-10-22 18:14:41 +0000433 PtrToFooMem.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &BarEntry);
434 PtrToFooMem.addValue(dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
435 &BarEntry);
436
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000437 DIEEntry PtrToFooMemRef(PtrToFooMem);
David Blaikied70a0552013-10-22 18:14:41 +0000438 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PtrToFooMemRef);
439
David Blaikie914046e2014-04-25 20:00:34 +0000440 Foo.addChild(std::move(Mem));
David Blaikied70a0552013-10-22 18:14:41 +0000441
David Blaikie2aee7be2013-10-24 18:29:03 +0000442 MD5ResDef = DIEHash().computeTypeSignature(Foo);
David Blaikied70a0552013-10-22 18:14:41 +0000443 }
444 // FIXME: This seems to be a bug in the DWARF type hashing specification that
445 // only uses the brief name hashing for types referenced via DW_AT_type. In
446 // this case the type is referenced via DW_AT_containing_type and full hashing
447 // causes a hash to differ when the containing type is a declaration in one TU
448 // and a definition in another.
449 ASSERT_NE(MD5ResDef, MD5ResDecl);
450}
David Blaikie32744412013-10-24 17:53:58 +0000451
452// struct { } a;
453// struct foo { decltype(a) mem; };
454TEST(DIEHashTest, RefUnnamedType) {
455 DIEInteger Zero(0);
456 DIEInteger One(1);
457 DIEInteger Eight(8);
458 DIEString FooStr(&Zero, "foo");
459 DIEString MemStr(&Zero, "mem");
460
461 DIE Unnamed(dwarf::DW_TAG_structure_type);
462 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
463
464 DIE Foo(dwarf::DW_TAG_structure_type);
465 Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
466 Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
467
David Blaikie914046e2014-04-25 20:00:34 +0000468 auto Mem = make_unique<DIE>(dwarf::DW_TAG_member);
David Blaikie32744412013-10-24 17:53:58 +0000469 Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
470 Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
471
472 DIE UnnamedPtr(dwarf::DW_TAG_pointer_type);
473 UnnamedPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000474 DIEEntry UnnamedRef(Unnamed);
David Blaikie32744412013-10-24 17:53:58 +0000475 UnnamedPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedRef);
476
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000477 DIEEntry UnnamedPtrRef(UnnamedPtr);
David Blaikie32744412013-10-24 17:53:58 +0000478 Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &UnnamedPtrRef);
479
David Blaikie914046e2014-04-25 20:00:34 +0000480 Foo.addChild(std::move(Mem));
David Blaikie32744412013-10-24 17:53:58 +0000481
David Blaikie2aee7be2013-10-24 18:29:03 +0000482 uint64_t MD5Res = DIEHash().computeTypeSignature(Foo);
David Blaikie32744412013-10-24 17:53:58 +0000483
484 ASSERT_EQ(0x954e026f01c02529ULL, MD5Res);
485}
David Blaikie65cc9692013-10-25 18:38:43 +0000486
Eric Christopher5ad8d902014-01-31 20:02:55 +0000487// struct { struct foo { }; };
David Blaikie65cc9692013-10-25 18:38:43 +0000488TEST(DIEHashTest, NestedType) {
489 DIE Unnamed(dwarf::DW_TAG_structure_type);
490 DIEInteger One(1);
491 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
492
David Blaikie914046e2014-04-25 20:00:34 +0000493 auto Foo = make_unique<DIE>(dwarf::DW_TAG_structure_type);
David Blaikie65cc9692013-10-25 18:38:43 +0000494 DIEString FooStr(&One, "foo");
495 Foo->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
496 Foo->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
497
David Blaikie914046e2014-04-25 20:00:34 +0000498 Unnamed.addChild(std::move(Foo));
David Blaikie65cc9692013-10-25 18:38:43 +0000499
500 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
501
502 // The exact same hash GCC produces for this DIE.
503 ASSERT_EQ(0xde8a3b7b43807f4aULL, MD5Res);
504}
David Blaikie8bc7db72013-10-25 20:04:25 +0000505
506// struct { static void func(); };
507TEST(DIEHashTest, MemberFunc) {
508 DIE Unnamed(dwarf::DW_TAG_structure_type);
509 DIEInteger One(1);
510 Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
511
David Blaikie914046e2014-04-25 20:00:34 +0000512 auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
David Blaikie8bc7db72013-10-25 20:04:25 +0000513 DIEString FuncStr(&One, "func");
514 Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr);
515
David Blaikie914046e2014-04-25 20:00:34 +0000516 Unnamed.addChild(std::move(Func));
David Blaikie8bc7db72013-10-25 20:04:25 +0000517
518 uint64_t MD5Res = DIEHash().computeTypeSignature(Unnamed);
519
520 // The exact same hash GCC produces for this DIE.
521 ASSERT_EQ(0xd36a1b6dfb604ba0ULL, MD5Res);
522}
Eric Christopher4b1cf582014-01-31 20:02:58 +0000523
524// struct A {
525// static void func();
526// };
527TEST(DIEHashTest, MemberFuncFlag) {
528 DIE A(dwarf::DW_TAG_structure_type);
529 DIEInteger One(1);
530 DIEString AStr(&One, "A");
531 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
532 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
533 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
534 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
535
David Blaikie914046e2014-04-25 20:00:34 +0000536 auto Func = make_unique<DIE>(dwarf::DW_TAG_subprogram);
Eric Christopher4b1cf582014-01-31 20:02:58 +0000537 DIEString FuncStr(&One, "func");
538 DIEString FuncLinkage(&One, "_ZN1A4funcEv");
539 DIEInteger Two(2);
540 Func->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
541 Func->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FuncStr);
542 Func->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
543 Func->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
544 Func->addValue(dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, &FuncLinkage);
545 Func->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
546
David Blaikie914046e2014-04-25 20:00:34 +0000547 A.addChild(std::move(Func));
Eric Christopher4b1cf582014-01-31 20:02:58 +0000548
549 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
550
551 // The exact same hash GCC produces for this DIE.
552 ASSERT_EQ(0x8f78211ddce3df10ULL, MD5Res);
553}
Eric Christopher8192ba22014-02-20 00:54:40 +0000554
555// Derived from:
556// struct A {
Eric Christopherf5ec3a02014-02-20 00:59:17 +0000557// const static int PI = -3;
Eric Christopher8192ba22014-02-20 00:54:40 +0000558// };
559// A a;
Eric Christopher1db80302014-02-20 01:27:51 +0000560TEST(DIEHashTest, MemberSdata) {
Eric Christopher8192ba22014-02-20 00:54:40 +0000561 DIE A(dwarf::DW_TAG_structure_type);
562 DIEInteger One(1);
563 DIEString AStr(&One, "A");
564 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
565 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
566 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
567 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
568
569 DIEInteger Four(4);
570 DIEInteger Five(5);
571 DIEString FStr(&One, "int");
David Blaikiede519a22014-04-25 17:07:55 +0000572 DIE IntTyDIE(dwarf::DW_TAG_base_type);
573 IntTyDIE.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
574 IntTyDIE.addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Five);
575 IntTyDIE.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
Eric Christopher8192ba22014-02-20 00:54:40 +0000576
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000577 DIEEntry IntTy(IntTyDIE);
David Blaikie914046e2014-04-25 20:00:34 +0000578 auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
Eric Christopher8192ba22014-02-20 00:54:40 +0000579 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &IntTy);
580
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000581 DIEEntry PITy(*PITyDIE);
David Blaikie914046e2014-04-25 20:00:34 +0000582 auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
Eric Christopher8192ba22014-02-20 00:54:40 +0000583 DIEString PIStr(&One, "PI");
584 DIEInteger Two(2);
585 DIEInteger NegThree(-3);
586 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
587 PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
588 PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
589 PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
590 PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
591 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
592 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, &NegThree);
593
David Blaikie914046e2014-04-25 20:00:34 +0000594 A.addChild(std::move(PI));
Eric Christopher8192ba22014-02-20 00:54:40 +0000595
Eric Christopher8192ba22014-02-20 00:54:40 +0000596 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
597 ASSERT_EQ(0x9a216000dd3788a7ULL, MD5Res);
598}
Eric Christopher420569b2014-02-20 02:50:45 +0000599
600// Derived from:
601// struct A {
602// const static float PI = 3.14;
603// };
604// A a;
605TEST(DIEHashTest, MemberBlock) {
606 DIE A(dwarf::DW_TAG_structure_type);
607 DIEInteger One(1);
608 DIEString AStr(&One, "A");
609 A.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &AStr);
610 A.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
611 A.addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
612 A.addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &One);
613
614 DIEInteger Four(4);
615 DIEString FStr(&One, "float");
David Blaikie914046e2014-04-25 20:00:34 +0000616 auto FloatTyDIE = make_unique<DIE>(dwarf::DW_TAG_base_type);
Eric Christopher420569b2014-02-20 02:50:45 +0000617 FloatTyDIE->addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Four);
618 FloatTyDIE->addValue(dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, &Four);
619 FloatTyDIE->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FStr);
620
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000621 DIEEntry FloatTy(*FloatTyDIE);
David Blaikie914046e2014-04-25 20:00:34 +0000622 auto PITyDIE = make_unique<DIE>(dwarf::DW_TAG_const_type);
Eric Christopher420569b2014-02-20 02:50:45 +0000623 PITyDIE->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FloatTy);
624
David Blaikie8dbcc3f2014-04-25 19:33:43 +0000625 DIEEntry PITy(*PITyDIE);
David Blaikie914046e2014-04-25 20:00:34 +0000626 auto PI = make_unique<DIE>(dwarf::DW_TAG_member);
Eric Christopher420569b2014-02-20 02:50:45 +0000627 DIEString PIStr(&One, "PI");
628 DIEInteger Two(2);
629 PI->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &PIStr);
630 PI->addValue(dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, &One);
631 PI->addValue(dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, &Two);
632 PI->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &PITy);
633 PI->addValue(dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, &One);
634 PI->addValue(dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, &One);
635
David Blaikiede519a22014-04-25 17:07:55 +0000636 DIEBlock PIBlock;
Eric Christopher420569b2014-02-20 02:50:45 +0000637 DIEInteger Blk1(0xc3);
638 DIEInteger Blk2(0xf5);
639 DIEInteger Blk3(0x48);
640 DIEInteger Blk4(0x40);
641
David Blaikiede519a22014-04-25 17:07:55 +0000642 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk1);
643 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk2);
644 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk3);
645 PIBlock.addValue((dwarf::Attribute)0, dwarf::DW_FORM_data1, &Blk4);
Eric Christopher420569b2014-02-20 02:50:45 +0000646
David Blaikiede519a22014-04-25 17:07:55 +0000647 PI->addValue(dwarf::DW_AT_const_value, dwarf::DW_FORM_block1, &PIBlock);
Eric Christopher420569b2014-02-20 02:50:45 +0000648
David Blaikie914046e2014-04-25 20:00:34 +0000649 A.addChild(std::move(PI));
Eric Christopher420569b2014-02-20 02:50:45 +0000650
651 uint64_t MD5Res = DIEHash().computeTypeSignature(A);
652 ASSERT_EQ(0x493af53ad3d3f651ULL, MD5Res);
653}
Eric Christopher25b7adc2013-09-03 21:57:57 +0000654}