LLVM  6.0.0svn
DWARFVisitor.h
Go to the documentation of this file.
1 //===--- DWARFVisitor.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 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_OBJECTYAML_DWARFVISITOR_H
13 #define LLVM_OBJECTYAML_DWARFVISITOR_H
14 
15 #include "llvm/ADT/StringRef.h"
18 
19 namespace llvm {
20 
21 namespace DWARFYAML {
22 
23 struct Data;
24 struct Unit;
25 struct Entry;
26 struct FormValue;
27 struct AttributeAbbrev;
28 
29 /// \brief A class to visits DWARFYAML Compile Units and DIEs in preorder.
30 ///
31 /// Extensions of this class can either maintain const or non-const references
32 /// to the DWARFYAML::Data object.
33 template <typename T> class VisitorImpl {
34 protected:
36 
37  /// Visitor Functions
38  /// @{
39  virtual void onStartCompileUnit(Unit &CU) {}
40  virtual void onEndCompileUnit(Unit &CU) {}
41  virtual void onStartDIE(Unit &CU, Entry &DIE) {}
42  virtual void onEndDIE(Unit &CU, Entry &DIE) {}
43  virtual void onForm(AttributeAbbrev &AttAbbrev, FormValue &Value) {}
44  /// @}
45 
46  /// Const Visitor Functions
47  /// @{
48  virtual void onStartCompileUnit(const Unit &CU) {}
49  virtual void onEndCompileUnit(const Unit &CU) {}
50  virtual void onStartDIE(const Unit &CU, const Entry &DIE) {}
51  virtual void onEndDIE(const Unit &CU, const Entry &DIE) {}
52  virtual void onForm(const AttributeAbbrev &AttAbbrev,
53  const FormValue &Value) {}
54  /// @}
55 
56  /// Value visitors
57  /// @{
58  virtual void onValue(const uint8_t U) {}
59  virtual void onValue(const uint16_t U) {}
60  virtual void onValue(const uint32_t U) {}
61  virtual void onValue(const uint64_t U, const bool LEB = false) {}
62  virtual void onValue(const int64_t S, const bool LEB = false) {}
63  virtual void onValue(const StringRef String) {}
64  virtual void onValue(const MemoryBufferRef MBR) {}
65  /// @}
66 
67 public:
68  VisitorImpl(T &DI) : DebugInfo(DI) {}
69 
70  virtual ~VisitorImpl() {}
71 
72  void traverseDebugInfo();
73 
74 private:
75  void onVariableSizeValue(uint64_t U, unsigned Size);
76 };
77 
78 // Making the visior instantiations extern and explicit in the cpp file. This
79 // prevents them from being instantiated in every compile unit that uses the
80 // visitors.
81 extern template class VisitorImpl<DWARFYAML::Data>;
82 extern template class VisitorImpl<const DWARFYAML::Data>;
83 
84 class Visitor : public VisitorImpl<Data> {
85 public:
86  Visitor(Data &DI) : VisitorImpl<Data>(DI) {}
87 };
88 
90 public:
91  ConstVisitor(const Data &DI) : VisitorImpl<const Data>(DI) {}
92 };
93 
94 } // namespace DWARFYAML
95 } // namespace llvm
96 
97 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
virtual void onForm(const AttributeAbbrev &AttAbbrev, const FormValue &Value)
Definition: DWARFVisitor.h:52
virtual void onValue(const int64_t S, const bool LEB=false)
Definition: DWARFVisitor.h:62
virtual void onValue(const uint16_t U)
Definition: DWARFVisitor.h:59
virtual void onStartDIE(const Unit &CU, const Entry &DIE)
Definition: DWARFVisitor.h:50
virtual void onForm(AttributeAbbrev &AttAbbrev, FormValue &Value)
Definition: DWARFVisitor.h:43
virtual void onStartDIE(Unit &CU, Entry &DIE)
Definition: DWARFVisitor.h:41
virtual void onEndDIE(const Unit &CU, const Entry &DIE)
Definition: DWARFVisitor.h:51
virtual void onValue(const uint64_t U, const bool LEB=false)
Definition: DWARFVisitor.h:61
virtual void onValue(const StringRef String)
Definition: DWARFVisitor.h:63
A structured debug information entry.
Definition: DIE.h:662
virtual void onStartCompileUnit(const Unit &CU)
Const Visitor Functions.
Definition: DWARFVisitor.h:48
A class to visits DWARFYAML Compile Units and DIEs in preorder.
Definition: DWARFVisitor.h:33
virtual void onValue(const uint8_t U)
Value visitors.
Definition: DWARFVisitor.h:58
virtual void onEndDIE(Unit &CU, Entry &DIE)
Definition: DWARFVisitor.h:42
This file contains constants used for implementing Dwarf debug support.
ConstVisitor(const Data &DI)
Definition: DWARFVisitor.h:91
virtual void onStartCompileUnit(Unit &CU)
Visitor Functions.
Definition: DWARFVisitor.h:39
virtual void onValue(const uint32_t U)
Definition: DWARFVisitor.h:60
virtual void onEndCompileUnit(Unit &CU)
Definition: DWARFVisitor.h:40
virtual void onValue(const MemoryBufferRef MBR)
Definition: DWARFVisitor.h:64
aarch64 promote const
LLVM Value Representation.
Definition: Value.h:73
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
virtual void onEndCompileUnit(const Unit &CU)
Definition: DWARFVisitor.h:49