[DebugInfo] Remove unneeded struct member and hide struct definition. No functionalit...
[oota-llvm.git] / include / llvm / DebugInfo / DWARFFormValue.h
1 //===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
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 #ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H
11 #define LLVM_DEBUGINFO_DWARFFORMVALUE_H
12
13 #include "llvm/Support/DataExtractor.h"
14
15 namespace llvm {
16
17 class DWARFUnit;
18 class raw_ostream;
19
20 class DWARFFormValue {
21   struct ValueType {
22     ValueType() : data(NULL) {
23       uval = 0;
24     }
25
26     union {
27       uint64_t uval;
28       int64_t sval;
29       const char* cstr;
30     };
31     const uint8_t* data;
32   };
33
34   uint16_t Form;   // Form for this value.
35   ValueType Value; // Contains all data for the form.
36
37 public:
38   DWARFFormValue(uint16_t form = 0) : Form(form) {}
39   uint16_t getForm() const { return Form; }
40   const ValueType& value() const { return Value; }
41   void dump(raw_ostream &OS, const DWARFUnit *U) const;
42   bool extractValue(DataExtractor data, uint32_t *offset_ptr,
43                     const DWARFUnit *u);
44   bool isInlinedCStr() const {
45     return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr;
46   }
47
48   uint64_t getReference(const DWARFUnit *U) const;
49   uint64_t getUnsigned() const { return Value.uval; }
50   int64_t getSigned() const { return Value.sval; }
51   const char *getAsCString(const DWARFUnit *U) const;
52   uint64_t getAsAddress(const DWARFUnit *U) const;
53
54   bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr,
55                  const DWARFUnit *u) const;
56   static bool skipValue(uint16_t form, DataExtractor debug_info_data,
57                         uint32_t *offset_ptr, const DWARFUnit *u);
58
59   static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version);
60 };
61
62 }
63
64 #endif