Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:39

0001 //===- DebugCrossImpSubsection.h --------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H
0011 
0012 #include "llvm/ADT/StringMap.h"
0013 #include "llvm/ADT/StringRef.h"
0014 #include "llvm/DebugInfo/CodeView/CodeView.h"
0015 #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
0016 #include "llvm/Support/BinaryStreamArray.h"
0017 #include "llvm/Support/BinaryStreamRef.h"
0018 #include "llvm/Support/Endian.h"
0019 #include "llvm/Support/Error.h"
0020 #include <cstdint>
0021 #include <vector>
0022 
0023 namespace llvm {
0024 class BinaryStreamReader;
0025 class BinaryStreamWriter;
0026 
0027 namespace codeview {
0028 
0029 struct CrossModuleImportItem {
0030   const CrossModuleImport *Header = nullptr;
0031   FixedStreamArray<support::ulittle32_t> Imports;
0032 };
0033 
0034 } // end namespace codeview
0035 
0036 template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> {
0037 public:
0038   using ContextType = void;
0039 
0040   Error operator()(BinaryStreamRef Stream, uint32_t &Len,
0041                    codeview::CrossModuleImportItem &Item);
0042 };
0043 
0044 namespace codeview {
0045 
0046 class DebugStringTableSubsection;
0047 
0048 class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef {
0049   using ReferenceArray = VarStreamArray<CrossModuleImportItem>;
0050   using Iterator = ReferenceArray::Iterator;
0051 
0052 public:
0053   DebugCrossModuleImportsSubsectionRef()
0054       : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {}
0055 
0056   static bool classof(const DebugSubsectionRef *S) {
0057     return S->kind() == DebugSubsectionKind::CrossScopeImports;
0058   }
0059 
0060   Error initialize(BinaryStreamReader Reader);
0061   Error initialize(BinaryStreamRef Stream);
0062 
0063   Iterator begin() const { return References.begin(); }
0064   Iterator end() const { return References.end(); }
0065 
0066 private:
0067   ReferenceArray References;
0068 };
0069 
0070 class DebugCrossModuleImportsSubsection final : public DebugSubsection {
0071 public:
0072   explicit DebugCrossModuleImportsSubsection(
0073       DebugStringTableSubsection &Strings)
0074       : DebugSubsection(DebugSubsectionKind::CrossScopeImports),
0075         Strings(Strings) {}
0076 
0077   static bool classof(const DebugSubsection *S) {
0078     return S->kind() == DebugSubsectionKind::CrossScopeImports;
0079   }
0080 
0081   void addImport(StringRef Module, uint32_t ImportId);
0082 
0083   uint32_t calculateSerializedSize() const override;
0084   Error commit(BinaryStreamWriter &Writer) const override;
0085 
0086 private:
0087   DebugStringTableSubsection &Strings;
0088   StringMap<std::vector<support::ulittle32_t>> Mappings;
0089 };
0090 
0091 } // end namespace codeview
0092 
0093 } // end namespace llvm
0094 
0095 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H