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