LLVM 20.0.0git
TypeVisitorCallbackPipeline.h
Go to the documentation of this file.
1//===- TypeVisitorCallbackPipeline.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_TYPEVISITORCALLBACKPIPELINE_H
10#define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H
11
15#include "llvm/Support/Error.h"
16#include <vector>
17
18namespace llvm {
19namespace codeview {
20
22public:
24
26 for (auto *Visitor : Pipeline) {
27 if (auto EC = Visitor->visitUnknownType(Record))
28 return EC;
29 }
30 return Error::success();
31 }
32
34 for (auto *Visitor : Pipeline) {
35 if (auto EC = Visitor->visitUnknownMember(Record))
36 return EC;
37 }
38 return Error::success();
39 }
40
42 for (auto *Visitor : Pipeline) {
43 if (auto EC = Visitor->visitTypeBegin(Record))
44 return EC;
45 }
46 return Error::success();
47 }
48
50 for (auto *Visitor : Pipeline) {
51 if (auto EC = Visitor->visitTypeBegin(Record, Index))
52 return EC;
53 }
54 return Error::success();
55 }
56
58 for (auto *Visitor : Pipeline) {
59 if (auto EC = Visitor->visitTypeEnd(Record))
60 return EC;
61 }
62 return Error::success();
63 }
64
66 for (auto *Visitor : Pipeline) {
67 if (auto EC = Visitor->visitMemberBegin(Record))
68 return EC;
69 }
70 return Error::success();
71 }
72
74 for (auto *Visitor : Pipeline) {
75 if (auto EC = Visitor->visitMemberEnd(Record))
76 return EC;
77 }
78 return Error::success();
79 }
80
82 Pipeline.push_back(&Callbacks);
83 }
84
85#define TYPE_RECORD(EnumName, EnumVal, Name) \
86 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override { \
87 return visitKnownRecordImpl(CVR, Record); \
88 }
89#define MEMBER_RECORD(EnumName, EnumVal, Name) \
90 Error visitKnownMember(CVMemberRecord &CVMR, Name##Record &Record) \
91 override { \
92 return visitKnownMemberImpl(CVMR, Record); \
93 }
94#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
95#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
96#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
97
98private:
99 template <typename T> Error visitKnownRecordImpl(CVType &CVR, T &Record) {
100 for (auto *Visitor : Pipeline) {
101 if (auto EC = Visitor->visitKnownRecord(CVR, Record))
102 return EC;
103 }
104 return Error::success();
105 }
106
107 template <typename T>
108 Error visitKnownMemberImpl(CVMemberRecord &CVMR, T &Record) {
109 for (auto *Visitor : Pipeline) {
110 if (auto EC = Visitor->visitKnownMember(CVMR, Record))
111 return EC;
112 }
113 return Error::success();
114 }
115 std::vector<TypeVisitorCallbacks *> Pipeline;
116};
117
118} // end namespace codeview
119} // end namespace llvm
120
121#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKPIPELINE_H
uint32_t Index
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:29
A 32-bit type reference.
Definition: TypeIndex.h:96
Error visitMemberBegin(CVMemberRecord &Record) override
Error visitTypeBegin(CVType &Record, TypeIndex Index) override
Error visitUnknownMember(CVMemberRecord &Record) override
Error visitMemberEnd(CVMemberRecord &Record) override
Error visitTypeBegin(CVType &Record) override
Paired begin/end actions for all types.
Error visitUnknownType(CVRecord< TypeLeafKind > &Record) override
void addCallbackToPipeline(TypeVisitorCallbacks &Callbacks)
CVRecord< TypeLeafKind > CVType
Definition: CVRecord.h:64
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18