blob: 9a3fcd8a783c1fbefdcccd3f7950aa55e36af664 [file] [log] [blame]
Benjamin Kramer72c0d7f2011-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
13#include "DWARFAttribute.h"
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/Support/DataExtractor.h"
16
17namespace llvm {
18
19class raw_ostream;
20
21class DWARFAbbreviationDeclaration {
22 uint32_t Code;
23 uint32_t Tag;
24 bool HasChildren;
Bill Wendling034b94b2012-12-19 07:18:57 +000025 SmallVector<DWARFAttribute, 8> Attribute;
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +000026public:
27 enum { InvalidCode = 0 };
28 DWARFAbbreviationDeclaration()
29 : Code(InvalidCode), Tag(0), HasChildren(0) {}
30
31 uint32_t getCode() const { return Code; }
32 uint32_t getTag() const { return Tag; }
33 bool hasChildren() const { return HasChildren; }
Bill Wendling034b94b2012-12-19 07:18:57 +000034 uint32_t getNumAttributes() const { return Attribute.size(); }
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +000035 uint16_t getAttrByIndex(uint32_t idx) const {
Bill Wendling034b94b2012-12-19 07:18:57 +000036 return Attribute.size() > idx ? Attribute[idx].getAttribute() : 0;
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +000037 }
38 uint16_t getFormByIndex(uint32_t idx) const {
Bill Wendling034b94b2012-12-19 07:18:57 +000039 return Attribute.size() > idx ? Attribute[idx].getForm() : 0;
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +000040 }
41
42 uint32_t findAttributeIndex(uint16_t attr) const;
43 bool extract(DataExtractor data, uint32_t* offset_ptr);
44 bool extract(DataExtractor data, uint32_t* offset_ptr, uint32_t code);
45 bool isValid() const { return Code != 0 && Tag != 0; }
46 void dump(raw_ostream &OS) const;
47 const SmallVectorImpl<DWARFAttribute> &getAttributes() const {
Bill Wendling034b94b2012-12-19 07:18:57 +000048 return Attribute;
Benjamin Kramer72c0d7f2011-09-13 19:42:23 +000049 }
50};
51
52}
53
54#endif