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