[llvm] [cmake] Add possibility to use ChooseMSVCCRT.cmake when include LLVM library
[llvm-core.git] / include / llvm / DebugInfo / CodeView / DebugCrossImpSubsection.h
blobe7683cb2a9c4a020769d7d58f0c05bdb10df321a
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 //===----------------------------------------------------------------------===//
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"
21 #include <cstdint>
22 #include <vector>
24 namespace llvm {
26 namespace codeview {
28 struct CrossModuleImportItem {
29 const CrossModuleImport *Header = nullptr;
30 FixedStreamArray<support::ulittle32_t> Imports;
33 } // end namespace codeview
35 template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
36 public:
37 using ContextType = void;
39 Error operator()(BinaryStreamRef Stream, uint32_t &Len,
40 codeview::CrossModuleImportItem &Item);
43 namespace codeview {
45 class DebugStringTableSubsection;
47 class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
48 using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
49 using Iterator = ReferenceArray::Iterator;
51 public:
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(); }
65 private:
66 ReferenceArray References;
69 class DebugCrossModuleImportsSubsection final : public DebugSubsection {
70 public:
71 explicit DebugCrossModuleImportsSubsection(
72 DebugStringTableSubsection &Strings)
73 : DebugSubsection(DebugSubsectionKind::CrossScopeImports),
74 Strings(Strings) {}
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;
85 private:
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