1 //===- TypeRecordMapping.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_TYPERECORDMAPPING_H 10 #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDMAPPING_H 11 12 #include "llvm/ADT/Optional.h" 13 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" 14 #include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" 15 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" 16 #include "llvm/Support/Error.h" 17 18 namespace llvm { 19 class BinaryStreamReader; 20 class BinaryStreamWriter; 21 22 namespace codeview { 23 class TypeRecordMapping : public TypeVisitorCallbacks { 24 public: 25 explicit TypeRecordMapping(BinaryStreamReader &Reader) : IO(Reader) {} 26 explicit TypeRecordMapping(BinaryStreamWriter &Writer) : IO(Writer) {} 27 explicit TypeRecordMapping(CodeViewRecordStreamer &Streamer) : IO(Streamer) {} 28 29 using TypeVisitorCallbacks::visitTypeBegin; 30 Error visitTypeBegin(CVType &Record) override; 31 Error visitTypeBegin(CVType &Record, TypeIndex Index) override; 32 Error visitTypeEnd(CVType &Record) override; 33 34 Error visitMemberBegin(CVMemberRecord &Record) override; 35 Error visitMemberEnd(CVMemberRecord &Record) override; 36 37 #define TYPE_RECORD(EnumName, EnumVal, Name) \ 38 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; 39 #define MEMBER_RECORD(EnumName, EnumVal, Name) \ 40 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; 41 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 42 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 43 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" 44 45 private: 46 Optional<TypeLeafKind> TypeKind; 47 Optional<TypeLeafKind> MemberKind; 48 49 CodeViewRecordIO IO; 50 }; 51 } 52 } 53 54 #endif 55