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_LIB_DEBUGINFO_DWARFABBREVIATIONDECLARATION_H
11 #define LLVM_LIB_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 public:
22   struct AttributeSpec {
AttributeSpecAttributeSpec23     AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {}
24     uint16_t Attr;
25     uint16_t Form;
26   };
27   typedef SmallVector<AttributeSpec, 8> AttributeSpecVector;
28 
29   DWARFAbbreviationDeclaration();
30 
getCode()31   uint32_t getCode() const { return Code; }
getTag()32   uint32_t getTag() const { return Tag; }
hasChildren()33   bool hasChildren() const { return HasChildren; }
34 
35   typedef iterator_range<AttributeSpecVector::const_iterator>
36   attr_iterator_range;
37 
attributes()38   attr_iterator_range attributes() const {
39     return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());
40   }
41 
getFormByIndex(uint32_t idx)42   uint16_t getFormByIndex(uint32_t idx) const {
43     return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0;
44   }
45 
46   uint32_t findAttributeIndex(uint16_t attr) const;
47   bool extract(DataExtractor Data, uint32_t* OffsetPtr);
48   void dump(raw_ostream &OS) const;
49 
50 private:
51   void clear();
52 
53   uint32_t Code;
54   uint32_t Tag;
55   bool HasChildren;
56 
57   AttributeSpecVector AttributeSpecs;
58 };
59 
60 }
61 
62 #endif
63