1//===- DebugCrossImpSubsection.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//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
10#define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
11
12#include "llvm/ADT/StringMap.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/DebugInfo/CodeView/CodeView.h"
15#include "llvm/DebugInfo/CodeView/DebugSubsection.h"
16#include "llvm/Support/BinaryStreamArray.h"
17#include "llvm/Support/BinaryStreamRef.h"
18#include "llvm/Support/Endian.h"
19#include "llvm/Support/Error.h"
20#include <cstdint>
21#include <vector>
22
23namespace llvm {
24class BinaryStreamReader;
25class BinaryStreamWriter;
26
27namespace codeview {
28
29struct CrossModuleImportItem {
30 const CrossModuleImport *Header = nullptr;
31 FixedStreamArray<support::ulittle32_t> Imports;
32};
33
34} // end namespace codeview
35
36template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
37public:
38 using ContextType = void;
39
40 Error operator()(BinaryStreamRef Stream, uint32_t &Len,
41 codeview::CrossModuleImportItem &Item);
42};
43
44namespace codeview {
45
46class DebugStringTableSubsection;
47
48class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
49 using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
50 using Iterator = ReferenceArray::Iterator;
51
52public:
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
66private:
67 ReferenceArray References;
68};
69
70class DebugCrossModuleImportsSubsection final : public DebugSubsection {
71public:
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
86private:
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
96

source code of llvm/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h