blob: e9b072eb86d8e497e609d236a9fc1eb54010a946 [file] [log] [blame]
Benjamin Krameraa2f78f2011-09-13 19:42:23 +00001//===-- 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 Krameraa2f78f2011-09-13 19:42:23 +000013#include "llvm/ADT/SmallVector.h"
14#include "llvm/Support/DataExtractor.h"
15
16namespace llvm {
17
18class raw_ostream;
19
20class DWARFAbbreviationDeclaration {
21 uint32_t Code;
22 uint32_t Tag;
23 bool HasChildren;
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000024
25 struct AttributeSpec {
26 AttributeSpec(uint16_t Attr, uint16_t Form) : Attr(Attr), Form(Form) {}
27 uint16_t Attr;
28 uint16_t Form;
29 };
30 SmallVector<AttributeSpec, 8> Attributes;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000031public:
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000032 DWARFAbbreviationDeclaration();
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000033
34 uint32_t getCode() const { return Code; }
35 uint32_t getTag() const { return Tag; }
36 bool hasChildren() const { return HasChildren; }
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000037 uint32_t getNumAttributes() const { return Attributes.size(); }
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000038 uint16_t getAttrByIndex(uint32_t idx) const {
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000039 return idx < Attributes.size() ? Attributes[idx].Attr : 0;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000040 }
41 uint16_t getFormByIndex(uint32_t idx) const {
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000042 return idx < Attributes.size() ? Attributes[idx].Form : 0;
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000043 }
44
45 uint32_t findAttributeIndex(uint16_t attr) const;
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000046 bool extract(DataExtractor Data, uint32_t* OffsetPtr);
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000047 void dump(raw_ostream &OS) const;
Alexey Samsonovd5cc93c2013-10-31 17:20:14 +000048
49private:
50 void clear();
Benjamin Krameraa2f78f2011-09-13 19:42:23 +000051};
52
53}
54
55#endif