]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/TypeDumpVisitor.h
Merge libc++ trunk r300890, and update build glue.
[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 visitTypeEnd(CVType &Record) override;
49   Error visitMemberBegin(CVMemberRecord &Record) override;
50   Error visitMemberEnd(CVMemberRecord &Record) override;
51
52 #define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
53   Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
54 #define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
55   Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
56 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
57 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
58 #include "TypeRecords.def"
59
60 private:
61   void printMemberAttributes(MemberAttributes Attrs);
62   void printMemberAttributes(MemberAccess Access, MethodKind Kind,
63                              MethodOptions Options);
64
65   /// Get the database of indices for the stream that we are dumping. If ItemDB
66   /// is set, then we must be dumping an item (IPI) stream. This will also
67   /// always get the appropriate DB for printing item names.
68   TypeDatabase &getSourceDB() const { return ItemDB ? *ItemDB : TypeDB; }
69
70   ScopedPrinter *W;
71
72   bool PrintRecordBytes = false;
73
74   TypeDatabase &TypeDB;
75   TypeDatabase *ItemDB = nullptr;
76 };
77
78 } // end namespace codeview
79 } // end namespace llvm
80
81 #endif