xref: /freebsd/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- DebugCrossExSubsection.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_DEBUGCROSSEXSUBSECTION_H
10 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H
11 
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
14 #include "llvm/Support/BinaryStreamArray.h"
15 #include "llvm/Support/BinaryStreamRef.h"
16 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/Error.h"
18 #include <cstdint>
19 #include <map>
20 
21 namespace llvm {
22 class BinaryStreamReader;
23 class BinaryStreamWriter;
24 namespace codeview {
25 
26 class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef {
27   using ReferenceArray = FixedStreamArray<CrossModuleExport>;
28   using Iterator = ReferenceArray::Iterator;
29 
30 public:
DebugCrossModuleExportsSubsectionRef()31   DebugCrossModuleExportsSubsectionRef()
32       : DebugSubsectionRef(DebugSubsectionKind::CrossScopeExports) {}
33 
classof(const DebugSubsectionRef * S)34   static bool classof(const DebugSubsectionRef *S) {
35     return S->kind() == DebugSubsectionKind::CrossScopeExports;
36   }
37 
38   LLVM_ABI Error initialize(BinaryStreamReader Reader);
39   LLVM_ABI Error initialize(BinaryStreamRef Stream);
40 
begin()41   Iterator begin() const { return References.begin(); }
end()42   Iterator end() const { return References.end(); }
43 
44 private:
45   FixedStreamArray<CrossModuleExport> References;
46 };
47 
48 class LLVM_ABI DebugCrossModuleExportsSubsection final
49     : public DebugSubsection {
50 public:
DebugCrossModuleExportsSubsection()51   DebugCrossModuleExportsSubsection()
52       : DebugSubsection(DebugSubsectionKind::CrossScopeExports) {}
53 
classof(const DebugSubsection * S)54   static bool classof(const DebugSubsection *S) {
55     return S->kind() == DebugSubsectionKind::CrossScopeExports;
56   }
57 
58   void addMapping(uint32_t Local, uint32_t Global);
59 
60   uint32_t calculateSerializedSize() const override;
61   Error commit(BinaryStreamWriter &Writer) const override;
62 
63 private:
64   std::map<uint32_t, uint32_t> Mappings;
65 };
66 
67 } // end namespace codeview
68 } // end namespace llvm
69 
70 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H
71