1 //===- DebugCrossImpSubsection.h --------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
10 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
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/BinaryStreamReader.h"
18 #include "llvm/Support/BinaryStreamRef.h"
19 #include "llvm/Support/Endian.h"
20 #include "llvm/Support/Error.h"
28 struct CrossModuleImportItem
{
29 const CrossModuleImport
*Header
= nullptr;
30 FixedStreamArray
<support::ulittle32_t
> Imports
;
33 } // end namespace codeview
35 template <> struct VarStreamArrayExtractor
<codeview::CrossModuleImportItem
> {
37 using ContextType
= void;
39 Error
operator()(BinaryStreamRef Stream
, uint32_t &Len
,
40 codeview::CrossModuleImportItem
&Item
);
45 class DebugStringTableSubsection
;
47 class DebugCrossModuleImportsSubsectionRef final
: public DebugSubsectionRef
{
48 using ReferenceArray
= VarStreamArray
<CrossModuleImportItem
>;
49 using Iterator
= ReferenceArray::Iterator
;
52 DebugCrossModuleImportsSubsectionRef()
53 : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports
) {}
55 static bool classof(const DebugSubsectionRef
*S
) {
56 return S
->kind() == DebugSubsectionKind::CrossScopeImports
;
59 Error
initialize(BinaryStreamReader Reader
);
60 Error
initialize(BinaryStreamRef Stream
);
62 Iterator
begin() const { return References
.begin(); }
63 Iterator
end() const { return References
.end(); }
66 ReferenceArray References
;
69 class DebugCrossModuleImportsSubsection final
: public DebugSubsection
{
71 explicit DebugCrossModuleImportsSubsection(
72 DebugStringTableSubsection
&Strings
)
73 : DebugSubsection(DebugSubsectionKind::CrossScopeImports
),
76 static bool classof(const DebugSubsection
*S
) {
77 return S
->kind() == DebugSubsectionKind::CrossScopeImports
;
80 void addImport(StringRef Module
, uint32_t ImportId
);
82 uint32_t calculateSerializedSize() const override
;
83 Error
commit(BinaryStreamWriter
&Writer
) const override
;
86 DebugStringTableSubsection
&Strings
;
87 StringMap
<std::vector
<support::ulittle32_t
>> Mappings
;
90 } // end namespace codeview
92 } // end namespace llvm
94 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H