[C++11] DWARF parser: use SmallVector<std::unique_ptr> for parsed units in DWARFConte...
[oota-llvm.git] / lib / DebugInfo / DWARFAbbreviationDeclaration.h
1 //===-- DWARFAbbreviationDeclaration.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_DWARFABBREVIATIONDECLARATION_H
11 #define LLVM_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
12
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/Support/DataExtractor.h"
15
16 namespace llvm {
17
18 class raw_ostream;
19
20 class DWARFAbbreviationDeclaration {
21   uint32_t Code;
22   uint32_t Tag;
23   bool HasChildren;
24
25   struct AttributeSpec {
26     uint16_t Attr;
27     uint16_t Form;
28   };
29   typedef SmallVector<AttributeSpec, 8> AttributeSpecVector;
30   AttributeSpecVector AttributeSpecs;
31 public:
32   DWARFAbbreviationDeclaration();
33
34   uint32_t getCode() const { return Code; }
35   uint32_t getTag() const { return Tag; }
36   bool hasChildren() const { return HasChildren; }
37
38   typedef iterator_range<AttributeSpecVector::const_iterator>
39   attr_iterator_range;
40
41   attr_iterator_range attributes() const {
42     return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());
43   }
44
45   uint16_t getFormByIndex(uint32_t idx) const {
46     return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0;
47   }
48
49   uint32_t findAttributeIndex(uint16_t attr) const;
50   bool extract(DataExtractor Data, uint32_t* OffsetPtr);
51   void dump(raw_ostream &OS) const;
52
53 private:
54   void clear();
55 };
56
57 }
58
59 #endif