Home | History | Annotate | Download | only in CodeView
      1 //===- TypeVisitorCallbacks.h -----------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H
     11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H
     12 
     13 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
     14 #include "llvm/Support/Error.h"
     15 
     16 namespace llvm {
     17 namespace codeview {
     18 
     19 class TypeVisitorCallbacks {
     20 public:
     21   virtual ~TypeVisitorCallbacks() = default;
     22 
     23   /// Action to take on unknown types. By default, they are ignored.
     24   virtual Error visitUnknownType(CVType &Record) { return Error::success(); }
     25   /// Paired begin/end actions for all types. Receives all record data,
     26   /// including the fixed-length record prefix.  visitTypeBegin() should return
     27   /// the type of the Record, or an error if it cannot be determined.  Exactly
     28   /// one of the two visitTypeBegin methods will be called, depending on whether
     29   /// records are being visited sequentially or randomly.  An implementation
     30   /// should be prepared to handle both (or assert if it can't handle random
     31   /// access visitation).
     32   virtual Error visitTypeBegin(CVType &Record) { return Error::success(); }
     33   virtual Error visitTypeBegin(CVType &Record, TypeIndex Index) {
     34     return Error::success();
     35   }
     36   virtual Error visitTypeEnd(CVType &Record) { return Error::success(); }
     37 
     38   virtual Error visitUnknownMember(CVMemberRecord &Record) {
     39     return Error::success();
     40   }
     41 
     42   virtual Error visitMemberBegin(CVMemberRecord &Record) {
     43     return Error::success();
     44   }
     45 
     46   virtual Error visitMemberEnd(CVMemberRecord &Record) {
     47     return Error::success();
     48   }
     49 
     50 #define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
     51   virtual Error visitKnownRecord(CVType &CVR, Name##Record &Record) {          \
     52     return Error::success();                                                   \
     53   }
     54 #define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
     55   virtual Error visitKnownMember(CVMemberRecord &CVM, Name##Record &Record) {  \
     56     return Error::success();                                                   \
     57   }
     58 
     59 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
     60 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
     61 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
     62 #undef TYPE_RECORD
     63 #undef TYPE_RECORD_ALIAS
     64 #undef MEMBER_RECORD
     65 #undef MEMBER_RECORD_ALIAS
     66 };
     67 
     68 } // end namespace codeview
     69 } // end namespace llvm
     70 
     71 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEVISITORCALLBACKS_H
     72