1 //===- TypeVisitorCallbacks.h -----------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H
10 #define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H
12 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
13 #include "llvm/Support/Error.h"
18 class TypeVisitorCallbacks {
20 virtual ~TypeVisitorCallbacks() = default;
22 /// Action to take on unknown types. By default, they are ignored.
23 virtual Error visitUnknownType(CVType &Record) { return Error::success(); }
24 /// Paired begin/end actions for all types. Receives all record data,
25 /// including the fixed-length record prefix. visitTypeBegin() should return
26 /// the type of the Record, or an error if it cannot be determined. Exactly
27 /// one of the two visitTypeBegin methods will be called, depending on whether
28 /// records are being visited sequentially or randomly. An implementation
29 /// should be prepared to handle both (or assert if it can't handle random
30 /// access visitation).
31 virtual Error visitTypeBegin(CVType &Record) { return Error::success(); }
32 virtual Error visitTypeBegin(CVType &Record, TypeIndex Index) {
33 return Error::success();
35 virtual Error visitTypeEnd(CVType &Record) { return Error::success(); }
37 virtual Error visitUnknownMember(CVMemberRecord &Record) {
38 return Error::success();
41 virtual Error visitMemberBegin(CVMemberRecord &Record) {
42 return Error::success();
45 virtual Error visitMemberEnd(CVMemberRecord &Record) {
46 return Error::success();
49 #define TYPE_RECORD(EnumName, EnumVal, Name) \
50 virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) { \
51 return Error::success(); \
53 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
54 virtual Error visitKnownMember(CVMemberRecord &CVM, Name##Record &Record) { \
55 return Error::success(); \
58 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
59 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
60 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
62 #undef TYPE_RECORD_ALIAS
64 #undef MEMBER_RECORD_ALIAS
67 } // end namespace codeview
68 } // end namespace llvm
70 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H