Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:40

0001 //===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
0010 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
0011 
0012 #include "llvm/ADT/StringRef.h"
0013 #include "llvm/DebugInfo/CodeView/CVRecord.h"
0014 #include "llvm/DebugInfo/CodeView/CodeView.h"
0015 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
0016 
0017 namespace llvm {
0018 class ScopedPrinter;
0019 
0020 namespace codeview {
0021 class TypeIndex;
0022 struct CVMemberRecord;
0023 struct MemberAttributes;
0024 
0025 class TypeCollection;
0026 
0027 /// Dumper for CodeView type streams found in COFF object files and PDB files.
0028 class TypeDumpVisitor : public TypeVisitorCallbacks {
0029 public:
0030   TypeDumpVisitor(TypeCollection &TpiTypes, ScopedPrinter *W,
0031                   bool PrintRecordBytes)
0032       : W(W), PrintRecordBytes(PrintRecordBytes), TpiTypes(TpiTypes) {}
0033 
0034   /// When dumping types from an IPI stream in a PDB, a type index may refer to
0035   /// a type or an item ID. The dumper will lookup the "name" of the index in
0036   /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
0037   /// which is correct when dumping types from an object file (/Z7).
0038   void setIpiTypes(TypeCollection &Types) { IpiTypes = &Types; }
0039 
0040   void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
0041 
0042   void printItemIndex(StringRef FieldName, TypeIndex TI) const;
0043 
0044   /// Action to take on unknown types. By default, they are ignored.
0045   Error visitUnknownType(CVType &Record) override;
0046   Error visitUnknownMember(CVMemberRecord &Record) override;
0047 
0048   /// Paired begin/end actions for all types. Receives all record data,
0049   /// including the fixed-length record prefix.
0050   Error visitTypeBegin(CVType &Record) override;
0051   Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
0052   Error visitTypeEnd(CVType &Record) override;
0053   Error visitMemberBegin(CVMemberRecord &Record) override;
0054   Error visitMemberEnd(CVMemberRecord &Record) override;
0055 
0056 #define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
0057   Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
0058 #define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
0059   Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
0060 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
0061 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
0062 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
0063 
0064 private:
0065   void printMemberAttributes(MemberAttributes Attrs);
0066   void printMemberAttributes(MemberAccess Access, MethodKind Kind,
0067                              MethodOptions Options);
0068 
0069   /// Get the database of indices for the stream that we are dumping. If ItemDB
0070   /// is set, then we must be dumping an item (IPI) stream. This will also
0071   /// always get the appropriate DB for printing item names.
0072   TypeCollection &getSourceTypes() const {
0073     return IpiTypes ? *IpiTypes : TpiTypes;
0074   }
0075 
0076   ScopedPrinter *W;
0077 
0078   bool PrintRecordBytes = false;
0079 
0080   TypeCollection &TpiTypes;
0081   TypeCollection *IpiTypes = nullptr;
0082 };
0083 
0084 } // end namespace codeview
0085 } // end namespace llvm
0086 
0087 #endif