blob: 04b859bdb9db81787b4923bee3279e937c898b80 [file] [log] [blame]
Alexey Samsonovcd614552013-04-17 08:29:02 +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 "llvm/DebugInfo/DWARFFormValue.h"
11#include "llvm/Support/Dwarf.h"
12#include "gtest/gtest.h"
13using namespace llvm;
14using namespace dwarf;
15
16namespace {
17
18TEST(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