[Alignment][NFC] Migrate Instructions to Align
[llvm-core.git] / include / llvm / DebugInfo / DWARF / DWARFDebugAbbrev.h
blob1398e16252a921c939eb90d9708603e8a54d15d3
1 //===- DWARFDebugAbbrev.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
10 #define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
12 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
13 #include "llvm/Support/DataExtractor.h"
14 #include <cstdint>
15 #include <map>
16 #include <vector>
18 namespace llvm {
20 class raw_ostream;
22 class DWARFAbbreviationDeclarationSet {
23 uint64_t Offset;
24 /// Code of the first abbreviation, if all abbreviations in the set have
25 /// consecutive codes. UINT32_MAX otherwise.
26 uint32_t FirstAbbrCode;
27 std::vector<DWARFAbbreviationDeclaration> Decls;
29 using const_iterator =
30 std::vector<DWARFAbbreviationDeclaration>::const_iterator;
32 public:
33 DWARFAbbreviationDeclarationSet();
35 uint64_t getOffset() const { return Offset; }
36 void dump(raw_ostream &OS) const;
37 bool extract(DataExtractor Data, uint64_t *OffsetPtr);
39 const DWARFAbbreviationDeclaration *
40 getAbbreviationDeclaration(uint32_t AbbrCode) const;
42 const_iterator begin() const {
43 return Decls.begin();
46 const_iterator end() const {
47 return Decls.end();
50 private:
51 void clear();
54 class DWARFDebugAbbrev {
55 using DWARFAbbreviationDeclarationSetMap =
56 std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
58 mutable DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
59 mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
60 mutable Optional<DataExtractor> Data;
62 public:
63 DWARFDebugAbbrev();
65 const DWARFAbbreviationDeclarationSet *
66 getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const;
68 void dump(raw_ostream &OS) const;
69 void parse() const;
70 void extract(DataExtractor Data);
72 DWARFAbbreviationDeclarationSetMap::const_iterator begin() const {
73 parse();
74 return AbbrDeclSets.begin();
77 DWARFAbbreviationDeclarationSetMap::const_iterator end() const {
78 return AbbrDeclSets.end();
81 private:
82 void clear();
85 } // end namespace llvm
87 #endif // LLVM_DEBUGINFO_DWARFDEBUGABBREV_H