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