summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-10-21 22:36:50 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-10-21 22:36:50 +0000
commitf1545a219744c1ae66137e64d1c456cd8e924eb7 (patch)
treeb187a8ab686cef6d3882343adc4f1768b5f9907c /unittests
parent65d60c8468a40df0ef4f5c152e7e8ce572785400 (diff)
downloadllvm-f1545a219744c1ae66137e64d1c456cd8e924eb7.tar.gz
llvm-f1545a219744c1ae66137e64d1c456cd8e924eb7.tar.bz2
llvm-f1545a219744c1ae66137e64d1c456cd8e924eb7.tar.xz
DWARF type hashing: begin implementing Step 5, summary hashing in declarable contexts
There are several other tag types that need similar handling but to ensure test coverage they'll be coming incrementally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CodeGen/DIEHashTest.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/unittests/CodeGen/DIEHashTest.cpp b/unittests/CodeGen/DIEHashTest.cpp
index 6c9cd89510..7d8b024e40 100644
--- a/unittests/CodeGen/DIEHashTest.cpp
+++ b/unittests/CodeGen/DIEHashTest.cpp
@@ -26,9 +26,8 @@ TEST(DIEHashTest, Data1) {
ASSERT_EQ(0x1AFE116E83701108ULL, MD5Res);
}
+// struct {};
TEST(DIEHashTest, TrivialType) {
- // A complete, but simple, type containing no members and defined on the first
- // line of a file.
DIE Unnamed(dwarf::DW_TAG_structure_type);
DIEInteger One(1);
Unnamed.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &One);
@@ -42,9 +41,8 @@ TEST(DIEHashTest, TrivialType) {
ASSERT_EQ(0x715305ce6cfd9ad1ULL, MD5Res);
}
+// struct foo { };
TEST(DIEHashTest, NamedType) {
- // A complete named type containing no members and defined on the first line
- // of a file.
DIE Foo(dwarf::DW_TAG_structure_type);
DIEInteger One(1);
DIEString FooStr(&One, "foo");
@@ -57,9 +55,8 @@ TEST(DIEHashTest, NamedType) {
ASSERT_EQ(0xd566dbd2ca5265ffULL, MD5Res);
}
+// namespace space { struct foo { }; }
TEST(DIEHashTest, NamespacedType) {
- // A complete named type containing no members and defined on the first line
- // of a file.
DIE CU(dwarf::DW_TAG_compile_unit);
DIE *Space = new DIE(dwarf::DW_TAG_namespace);
@@ -84,6 +81,7 @@ TEST(DIEHashTest, NamespacedType) {
ASSERT_EQ(0x7b80381fd17f1e33ULL, MD5Res);
}
+// struct { int member; };
TEST(DIEHashTest, TypeWithMember) {
DIE Unnamed(dwarf::DW_TAG_structure_type);
DIEInteger Four(4);
@@ -112,6 +110,7 @@ TEST(DIEHashTest, TypeWithMember) {
ASSERT_EQ(0x5646aa436b7e07c6ULL, MD5Res);
}
+// struct foo { int mem1, mem2; };
TEST(DIEHashTest, ReusedType) {
DIE Unnamed(dwarf::DW_TAG_structure_type);
DIEInteger Eight(8);
@@ -149,6 +148,7 @@ TEST(DIEHashTest, ReusedType) {
ASSERT_EQ(0x3a7dc3ed7b76b2f8ULL, MD5Res);
}
+// struct foo { static foo f; };
TEST(DIEHashTest, RecursiveType) {
DIE Foo(dwarf::DW_TAG_structure_type);
DIEInteger One(1);
@@ -169,4 +169,33 @@ TEST(DIEHashTest, RecursiveType) {
ASSERT_EQ(0x73d8b25aef227b06ULL, MD5Res);
}
+
+// struct foo { foo *mem; };
+TEST(DIEHashTest, Pointer) {
+ DIE Foo(dwarf::DW_TAG_structure_type);
+ DIEInteger Eight(8);
+ Foo.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
+ DIEString FooStr(&Eight, "foo");
+ Foo.addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &FooStr);
+
+ DIE *Mem = new DIE(dwarf::DW_TAG_member);
+ DIEString MemStr(&Eight, "mem");
+ Mem->addValue(dwarf::DW_AT_name, dwarf::DW_FORM_strp, &MemStr);
+ DIEInteger Zero(0);
+ Mem->addValue(dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, &Zero);
+
+ DIE FooPtr(dwarf::DW_TAG_pointer_type);
+ FooPtr.addValue(dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, &Eight);
+ DIEEntry FooRef(&Foo);
+ FooPtr.addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooRef);
+
+ DIEEntry FooPtrRef(&FooPtr);
+ Mem->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, &FooPtrRef);
+
+ Foo.addChild(Mem);
+
+ uint64_t MD5Res = DIEHash().computeTypeSignature(&Foo);
+
+ ASSERT_EQ(0x74ea73862e8708d2ULL, MD5Res);
+}
}