Home | History | Annotate | Download | only in DebugInfo
      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 "DWARFAttribute.h"
     14 #include "llvm/ADT/SmallVector.h"
     15 #include "llvm/Support/DataExtractor.h"
     16 
     17 namespace llvm {
     18 
     19 class raw_ostream;
     20 
     21 class DWARFAbbreviationDeclaration {
     22   uint32_t Code;
     23   uint32_t Tag;
     24   bool HasChildren;
     25   SmallVector<DWARFAttribute, 8> Attributes;
     26 public:
     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; }
     34   uint32_t getNumAttributes() const { return Attributes.size(); }
     35   uint16_t getAttrByIndex(uint32_t idx) const {
     36     return Attributes.size() > idx ? Attributes[idx].getAttribute() : 0;
     37   }
     38   uint16_t getFormByIndex(uint32_t idx) const {
     39     return Attributes.size() > idx ? Attributes[idx].getForm() : 0;
     40   }
     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 {
     48     return Attributes;
     49   }
     50 };
     51 
     52 }
     53 
     54 #endif
     55