Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 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; |
Alexey Samsonov | d5cc93c | 2013-10-31 17:20:14 +0000 | [diff] [blame] | 24 | |
| 25 | struct AttributeSpec { |
Alexey Samsonov | 4d97203 | 2014-03-14 10:37:36 +0000 | [diff] [blame] | 26 | AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {} |
Alexey Samsonov | d5cc93c | 2013-10-31 17:20:14 +0000 | [diff] [blame] | 27 | uint16_t Attr; |
| 28 | uint16_t Form; |
| 29 | }; |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 30 | typedef SmallVector<AttributeSpec, 8> AttributeSpecVector; |
| 31 | AttributeSpecVector AttributeSpecs; |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 32 | public: |
Alexey Samsonov | d5cc93c | 2013-10-31 17:20:14 +0000 | [diff] [blame] | 33 | DWARFAbbreviationDeclaration(); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 34 | |
| 35 | uint32_t getCode() const { return Code; } |
| 36 | uint32_t getTag() const { return Tag; } |
| 37 | bool hasChildren() const { return HasChildren; } |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 38 | |
| 39 | typedef iterator_range<AttributeSpecVector::const_iterator> |
| 40 | attr_iterator_range; |
| 41 | |
| 42 | attr_iterator_range attributes() const { |
| 43 | return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end()); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 44 | } |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 45 | |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 46 | uint16_t getFormByIndex(uint32_t idx) const { |
Alexey Samsonov | 1eabf98 | 2014-03-13 07:52:54 +0000 | [diff] [blame] | 47 | return idx < AttributeSpecs.size() ? AttributeSpecs[idx].Form : 0; |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | uint32_t findAttributeIndex(uint16_t attr) const; |
Alexey Samsonov | d5cc93c | 2013-10-31 17:20:14 +0000 | [diff] [blame] | 51 | bool extract(DataExtractor Data, uint32_t* OffsetPtr); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 52 | void dump(raw_ostream &OS) const; |
Alexey Samsonov | d5cc93c | 2013-10-31 17:20:14 +0000 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | void clear(); |
Benjamin Kramer | aa2f78f | 2011-09-13 19:42:23 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | #endif |