]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h
Merge lldb trunk r321414 to contrib/llvm/tools/lldb.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / DebugCrossImpSubsection.h
1 //===- DebugCrossExSubsection.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_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
11 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
12
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/DebugInfo/CodeView/CodeView.h"
16 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
17 #include "llvm/Support/BinaryStreamArray.h"
18 #include "llvm/Support/BinaryStreamReader.h"
19 #include "llvm/Support/BinaryStreamRef.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
22 #include <cstdint>
23 #include <vector>
24
25 namespace llvm {
26
27 namespace codeview {
28
29 struct CrossModuleImportItem {
30   const CrossModuleImport *Header = nullptr;
31   FixedStreamArray<support::ulittle32_t> Imports;
32 };
33
34 } // end namespace codeview
35
36 template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
37 public:
38   using ContextType = void;
39
40   Error operator()(BinaryStreamRef Stream, uint32_t &Len,
41                    codeview::CrossModuleImportItem &Item);
42 };
43
44 namespace codeview {
45
46 class DebugStringTableSubsection;
47
48 class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
49   using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
50   using Iterator = ReferenceArray::Iterator;
51
52 public:
53   DebugCrossModuleImportsSubsectionRef()
54       : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {}
55
56   static bool classof(const DebugSubsectionRef *S) {
57     return S->kind() == DebugSubsectionKind::CrossScopeImports;
58   }
59
60   Error initialize(BinaryStreamReader Reader);
61   Error initialize(BinaryStreamRef Stream);
62
63   Iterator begin() const { return References.begin(); }
64   Iterator end() const { return References.end(); }
65
66 private:
67   ReferenceArray References;
68 };
69
70 class DebugCrossModuleImportsSubsection final : public DebugSubsection {
71 public:
72   explicit DebugCrossModuleImportsSubsection(
73       DebugStringTableSubsection &Strings)
74       : DebugSubsection(DebugSubsectionKind::CrossScopeImports),
75         Strings(Strings) {}
76
77   static bool classof(const DebugSubsection *S) {
78     return S->kind() == DebugSubsectionKind::CrossScopeImports;
79   }
80
81   void addImport(StringRef Module, uint32_t ImportId);
82
83   uint32_t calculateSerializedSize() const override;
84   Error commit(BinaryStreamWriter &Writer) const override;
85
86 private:
87   DebugStringTableSubsection &Strings;
88   StringMap<std::vector<support::ulittle32_t>> Mappings;
89 };
90
91 } // end namespace codeview
92
93 } // end namespace llvm
94
95 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H