summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo/DWARFFormValueTest.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-10-28 23:01:48 +0000
committerAlexey Samsonov <samsonov@google.com>2013-10-28 23:01:48 +0000
commit48cbda5850264671e982ecdd834c1587b1732c15 (patch)
treefceb336b9978d09dbaa90b78b3ee5028c40e6b19 /llvm/unittests/DebugInfo/DWARFFormValueTest.cpp
parent0a09ebf445339748b549d7c8743fcb7e435d3527 (diff)
downloadbcm5719-llvm-48cbda5850264671e982ecdd834c1587b1732c15.tar.gz
bcm5719-llvm-48cbda5850264671e982ecdd834c1587b1732c15.zip
DebugInfo: Introduce the notion of "form classes"
Summary: Use DWARF4 table of form classes to fetch attributes from DIE in a more consistent way. This shouldn't change the functionality and serves as a refactoring for upcoming change: DW_AT_high_pc has different semantics depending on its form class. Reviewers: dblaikie, echristo Reviewed By: echristo CC: echristo, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1961 llvm-svn: 193553
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARFFormValueTest.cpp')
-rw-r--r--llvm/unittests/DebugInfo/DWARFFormValueTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/DebugInfo/DWARFFormValueTest.cpp b/llvm/unittests/DebugInfo/DWARFFormValueTest.cpp
index 04b859bdb9d..e7216b3726f 100644
--- a/llvm/unittests/DebugInfo/DWARFFormValueTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARFFormValueTest.cpp
@@ -28,4 +28,21 @@ TEST(DWARFFormValue, FixedFormSizes) {
EXPECT_EQ(0, DWARFFormValue::getFixedFormSizes(16, 2));
}
+bool isFormClass(uint16_t Form, DWARFFormValue::FormClass FC) {
+ return DWARFFormValue(Form).isFormClass(FC);
+}
+
+TEST(DWARFFormValue, FormClass) {
+ EXPECT_TRUE(isFormClass(DW_FORM_addr, DWARFFormValue::FC_Address));
+ EXPECT_FALSE(isFormClass(DW_FORM_data8, DWARFFormValue::FC_Address));
+ EXPECT_TRUE(isFormClass(DW_FORM_data8, DWARFFormValue::FC_Constant));
+ EXPECT_TRUE(isFormClass(DW_FORM_data8, DWARFFormValue::FC_SectionOffset));
+ EXPECT_TRUE(
+ isFormClass(DW_FORM_sec_offset, DWARFFormValue::FC_SectionOffset));
+ EXPECT_TRUE(isFormClass(DW_FORM_GNU_str_index, DWARFFormValue::FC_String));
+ EXPECT_TRUE(isFormClass(DW_FORM_GNU_addr_index, DWARFFormValue::FC_Address));
+ EXPECT_FALSE(isFormClass(DW_FORM_ref_addr, DWARFFormValue::FC_Address));
+ EXPECT_TRUE(isFormClass(DW_FORM_ref_addr, DWARFFormValue::FC_Reference));
+}
+
} // end anonymous namespace
OpenPOWER on IntegriCloud