1 //===- DebugCrossExSubsection.h ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
11 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
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"
29 struct CrossModuleImportItem {
30 const CrossModuleImport *Header = nullptr;
31 FixedStreamArray<support::ulittle32_t> Imports;
34 } // end namespace codeview
36 template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
38 using ContextType = void;
40 Error operator()(BinaryStreamRef Stream, uint32_t &Len,
41 codeview::CrossModuleImportItem &Item);
46 class DebugStringTableSubsection;
48 class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
49 using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
50 using Iterator = ReferenceArray::Iterator;
53 DebugCrossModuleImportsSubsectionRef()
54 : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {}
56 static bool classof(const DebugSubsectionRef *S) {
57 return S->kind() == DebugSubsectionKind::CrossScopeImports;
60 Error initialize(BinaryStreamReader Reader);
61 Error initialize(BinaryStreamRef Stream);
63 Iterator begin() const { return References.begin(); }
64 Iterator end() const { return References.end(); }
67 ReferenceArray References;
70 class DebugCrossModuleImportsSubsection final : public DebugSubsection {
72 explicit DebugCrossModuleImportsSubsection(
73 DebugStringTableSubsection &Strings)
74 : DebugSubsection(DebugSubsectionKind::CrossScopeImports),
77 static bool classof(const DebugSubsection *S) {
78 return S->kind() == DebugSubsectionKind::CrossScopeImports;
81 void addImport(StringRef Module, uint32_t ImportId);
83 uint32_t calculateSerializedSize() const override;
84 Error commit(BinaryStreamWriter &Writer) const override;
87 DebugStringTableSubsection &Strings;
88 StringMap<std::vector<support::ulittle32_t>> Mappings;
91 } // end namespace codeview
93 } // end namespace llvm
95 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H