1 //===- TypeVisitorCallbacks.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_TYPEVISITORCALLBACKS_H 10 #define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H 11 12 #include "llvm/DebugInfo/CodeView/TypeRecord.h" 13 #include "llvm/Support/Error.h" 14 15 namespace llvm { 16 namespace codeview { 17 18 class TypeVisitorCallbacks { 19 public: 20 virtual ~TypeVisitorCallbacks() = default; 21 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(); 34 } 35 virtual Error visitTypeEnd(CVType &Record) { return Error::success(); } 36 37 virtual Error visitUnknownMember(CVMemberRecord &Record) { 38 return Error::success(); 39 } 40 41 virtual Error visitMemberBegin(CVMemberRecord &Record) { 42 return Error::success(); 43 } 44 45 virtual Error visitMemberEnd(CVMemberRecord &Record) { 46 return Error::success(); 47 } 48 49 #define TYPE_RECORD(EnumName, EnumVal, Name) \ 50 virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) { \ 51 return Error::success(); \ 52 } 53 #define MEMBER_RECORD(EnumName, EnumVal, Name) \ 54 virtual Error visitKnownMember(CVMemberRecord &CVM, Name##Record &Record) { \ 55 return Error::success(); \ 56 } 57 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" 61 #undef TYPE_RECORD 62 #undef TYPE_RECORD_ALIAS 63 #undef MEMBER_RECORD 64 #undef MEMBER_RECORD_ALIAS 65 }; 66 67 } // end namespace codeview 68 } // end namespace llvm 69 70 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H 71