Line data Source code
1 : //===- CVTypeVisitor.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_CVTYPEVISITOR_H
11 : #define LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H
12 :
13 : #include "llvm/ADT/TinyPtrVector.h"
14 : #include "llvm/DebugInfo/CodeView/CVRecord.h"
15 : #include "llvm/DebugInfo/CodeView/TypeRecord.h"
16 : #include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
17 : #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
18 : #include "llvm/Support/Error.h"
19 :
20 : namespace llvm {
21 : namespace codeview {
22 :
23 5827 : class CVTypeVisitor {
24 : public:
25 : explicit CVTypeVisitor(TypeVisitorCallbacks &Callbacks);
26 :
27 : void addTypeServerHandler(TypeServerHandler &Handler);
28 :
29 : Error visitTypeRecord(CVType &Record, TypeIndex Index);
30 : Error visitTypeRecord(CVType &Record);
31 : Error visitMemberRecord(CVMemberRecord Record);
32 :
33 : /// Visits the type records in Data. Sets the error flag on parse failures.
34 : Error visitTypeStream(const CVTypeArray &Types);
35 : Error visitTypeStream(CVTypeRange Types);
36 :
37 : Error visitFieldListMemberStream(ArrayRef<uint8_t> FieldList);
38 : Error visitFieldListMemberStream(BinaryStreamReader Reader);
39 :
40 : private:
41 : Expected<bool> handleTypeServer(CVType &Record);
42 : Error finishVisitation(CVType &Record);
43 :
44 : /// The interface to the class that gets notified of each visitation.
45 : TypeVisitorCallbacks &Callbacks;
46 :
47 : TinyPtrVector<TypeServerHandler *> Handlers;
48 : };
49 :
50 : enum VisitorDataSource {
51 : VDS_BytesPresent, // The record bytes are passed into the the visitation
52 : // function. The algorithm should first deserialize them
53 : // before passing them on through the pipeline.
54 : VDS_BytesExternal // The record bytes are not present, and it is the
55 : // responsibility of the visitor callback interface to
56 : // supply the bytes.
57 : };
58 :
59 : Error visitTypeRecord(CVType &Record, TypeIndex Index,
60 : TypeVisitorCallbacks &Callbacks,
61 : VisitorDataSource Source = VDS_BytesPresent,
62 : TypeServerHandler *TS = nullptr);
63 : Error visitTypeRecord(CVType &Record, TypeVisitorCallbacks &Callbacks,
64 : VisitorDataSource Source = VDS_BytesPresent,
65 : TypeServerHandler *TS = nullptr);
66 :
67 : Error visitMemberRecord(CVMemberRecord Record, TypeVisitorCallbacks &Callbacks,
68 : VisitorDataSource Source = VDS_BytesPresent);
69 : Error visitMemberRecord(TypeLeafKind Kind, ArrayRef<uint8_t> Record,
70 : TypeVisitorCallbacks &Callbacks);
71 :
72 : Error visitMemberRecordStream(ArrayRef<uint8_t> FieldList,
73 : TypeVisitorCallbacks &Callbacks);
74 :
75 : Error visitTypeStream(const CVTypeArray &Types, TypeVisitorCallbacks &Callbacks,
76 : TypeServerHandler *TS = nullptr);
77 : Error visitTypeStream(CVTypeRange Types, TypeVisitorCallbacks &Callbacks,
78 : TypeServerHandler *TS = nullptr);
79 :
80 : } // end namespace codeview
81 : } // end namespace llvm
82 :
83 : #endif // LLVM_DEBUGINFO_CODEVIEW_CVTYPEVISITOR_H
|