1 //===- 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 "llvm/DebugInfo/DWARFFormValue.h" 11 #include "llvm/Support/Dwarf.h" 12 #include "gtest/gtest.h" 13 using namespace llvm; 14 using namespace dwarf; 15 16 namespace { 17 18 TEST(DWARFFormValue, FixedFormSizes) { 19 // Size of DW_FORM_addr and DW_FORM_ref_addr are equal in DWARF2, 20 // DW_FORM_ref_addr is always 4 bytes in DWARF32 starting from DWARF3. 21 const uint8_t *sizes = DWARFFormValue::getFixedFormSizes(4, 2); 22 EXPECT_EQ(sizes[DW_FORM_addr], sizes[DW_FORM_ref_addr]); 23 sizes = DWARFFormValue::getFixedFormSizes(8, 2); 24 EXPECT_EQ(sizes[DW_FORM_addr], sizes[DW_FORM_ref_addr]); 25 sizes = DWARFFormValue::getFixedFormSizes(8, 3); 26 EXPECT_EQ(4, sizes[DW_FORM_ref_addr]); 27 // Check that we don't have fixed form sizes for weird address sizes. 28 EXPECT_EQ(0, DWARFFormValue::getFixedFormSizes(16, 2)); 29 } 30 31 } // end anonymous namespace 32