]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h
Merge ^/head r318380 through r318559.
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / TypeDumpVisitor.h
1 //===-- TypeDumpVisitor.h - CodeView type info dumper -----------*- 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_TYPEDUMPVISITOR_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPVISITOR_H
12
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/StringSet.h"
15 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
16 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
17 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
18 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
19
20 namespace llvm {
21 class ScopedPrinter;
22
23 namespace codeview {
24
25 /// Dumper for CodeView type streams found in COFF object files and PDB files.
26 class TypeDumpVisitor : public TypeVisitorCallbacks {
27 public:
28   TypeDumpVisitor(TypeDatabase &TypeDB, ScopedPrinter *W, bool PrintRecordBytes)
29       : W(W), PrintRecordBytes(PrintRecordBytes), TypeDB(TypeDB) {}
30
31   /// When dumping types from an IPI stream in a PDB, a type index may refer to
32   /// a type or an item ID. The dumper will lookup the "name" of the index in
33   /// the item database if appropriate. If ItemDB is null, it will use TypeDB,
34   /// which is correct when dumping types from an object file (/Z7).
35   void setItemDB(TypeDatabase &DB) { ItemDB = &DB; }
36
37   void printTypeIndex(StringRef FieldName, TypeIndex TI) const;
38
39   void printItemIndex(StringRef FieldName, TypeIndex TI) const;
40
41   /// Action to take on unknown types. By default, they are ignored.
42   Error visitUnknownType(CVType &Record) override;
43   Error visitUnknownMember(CVMemberRecord &Record) override;
44
45   /// Paired begin/end actions for all types. Receives all record data,
46   /// including the fixed-length record prefix.
47   Error visitTypeBegin(CVType &Record) override;
48   Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
49   Error visitTypeEnd(CVType &Record) override;
50   Error visitMemberBegin(CVMemberRecord &Record) override;
51   Error visitMemberEnd(CVMemberRecord &Record) override;
52
53 #define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
54   Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
55 #define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
56   Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
57 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
58 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
59 #include "TypeRecords.def"
60
61 private:
62   void printMemberAttributes(MemberAttributes Attrs);
63   void printMemberAttributes(MemberAccess Access, MethodKind Kind,
64                              MethodOptions Options);
65
66   /// Get the database of indices for the stream that we are dumping. If ItemDB
67   /// is set, then we must be dumping an item (IPI) stream. This will also
68   /// always get the appropriate DB for printing item names.
69   TypeDatabase &getSourceDB() const { return ItemDB ? *ItemDB : TypeDB; }
70
71   ScopedPrinter *W;
72
73   bool PrintRecordBytes = false;
74
75   TypeDatabase &TypeDB;
76   TypeDatabase *ItemDB = nullptr;
77 };
78
79 } // end namespace codeview
80 } // end namespace llvm
81
82 #endif