1 //===- DebugCrossExSubsection.h ---------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H 11 #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H 12 13 #include "llvm/ADT/StringMap.h" 14 #include "llvm/DebugInfo/CodeView/DebugSubsection.h" 15 #include "llvm/Support/BinaryStreamArray.h" 16 #include "llvm/Support/BinaryStreamReader.h" 17 #include "llvm/Support/Endian.h" 18 19 namespace llvm { 20 namespace codeview { 21 22 struct CrossModuleImportItem { 23 const CrossModuleImport *Header = nullptr; 24 llvm::FixedStreamArray<support::ulittle32_t> Imports; 25 }; 26 } 27 } 28 29 namespace llvm { 30 template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> { 31 public: 32 typedef void ContextType; 33 34 Error operator()(BinaryStreamRef Stream, uint32_t &Len, 35 codeview::CrossModuleImportItem &Item); 36 }; 37 } 38 39 namespace llvm { 40 namespace codeview { 41 class DebugStringTableSubsection; 42 43 class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef { 44 typedef VarStreamArray<CrossModuleImportItem> ReferenceArray; 45 typedef ReferenceArray::Iterator Iterator; 46 47 public: 48 DebugCrossModuleImportsSubsectionRef() 49 : DebugSubsectionRef(DebugSubsectionKind::CrossScopeImports) {} 50 51 static bool classof(const DebugSubsectionRef *S) { 52 return S->kind() == DebugSubsectionKind::CrossScopeImports; 53 } 54 55 Error initialize(BinaryStreamReader Reader); 56 Error initialize(BinaryStreamRef Stream); 57 58 Iterator begin() const { return References.begin(); } 59 Iterator end() const { return References.end(); } 60 61 private: 62 ReferenceArray References; 63 }; 64 65 class DebugCrossModuleImportsSubsection final : public DebugSubsection { 66 public: 67 explicit DebugCrossModuleImportsSubsection( 68 DebugStringTableSubsection &Strings) 69 : DebugSubsection(DebugSubsectionKind::CrossScopeImports), 70 Strings(Strings) {} 71 72 static bool classof(const DebugSubsection *S) { 73 return S->kind() == DebugSubsectionKind::CrossScopeImports; 74 } 75 76 void addImport(StringRef Module, uint32_t ImportId); 77 78 uint32_t calculateSerializedSize() const override; 79 Error commit(BinaryStreamWriter &Writer) const override; 80 81 private: 82 DebugStringTableSubsection &Strings; 83 StringMap<std::vector<support::ulittle32_t>> Mappings; 84 }; 85 } 86 } 87 88 #endif 89