LLVM  10.0.0svn
DWARFVisitor.h
Go to the documentation of this file.
1 //===--- DWARFVisitor.h -----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //===----------------------------------------------------------------------===//
10 
11 #ifndef LLVM_OBJECTYAML_DWARFVISITOR_H
12 #define LLVM_OBJECTYAML_DWARFVISITOR_H
13 
14 #include "llvm/ADT/StringRef.h"
17 
18 namespace llvm {
19 
20 namespace DWARFYAML {
21 
22 struct Data;
23 struct Unit;
24 struct Entry;
25 struct FormValue;
26 struct AttributeAbbrev;
27 
28 /// A class to visits DWARFYAML Compile Units and DIEs in preorder.
29 ///
30 /// Extensions of this class can either maintain const or non-const references
31 /// to the DWARFYAML::Data object.
32 template <typename T> class VisitorImpl {
33 protected:
35 
36  /// Visitor Functions
37  /// @{
38  virtual void onStartCompileUnit(Unit &CU) {}
39  virtual void onEndCompileUnit(Unit &CU) {}
40  virtual void onStartDIE(Unit &CU, Entry &DIE) {}
41  virtual void onEndDIE(Unit &CU, Entry &DIE) {}
42  virtual void onForm(AttributeAbbrev &AttAbbrev, FormValue &Value) {}
43  /// @}
44 
45  /// Const Visitor Functions
46  /// @{
47  virtual void onStartCompileUnit(const Unit &CU) {}
48  virtual void onEndCompileUnit(const Unit &CU) {}
49  virtual void onStartDIE(const Unit &CU, const Entry &DIE) {}
50  virtual void onEndDIE(const Unit &CU, const Entry &DIE) {}
51  virtual void onForm(const AttributeAbbrev &AttAbbrev,
52  const FormValue &Value) {}
53  /// @}
54 
55  /// Value visitors
56  /// @{
57  virtual void onValue(const uint8_t U) {}
58  virtual void onValue(const uint16_t U) {}
59  virtual void onValue(const uint32_t U) {}
60  virtual void onValue(const uint64_t U, const bool LEB = false) {}
61  virtual void onValue(const int64_t S, const bool LEB = false) {}
62  virtual void onValue(const StringRef String) {}
63  virtual void onValue(const MemoryBufferRef MBR) {}
64  /// @}
65 
66 public:
67  VisitorImpl(T &DI) : DebugInfo(DI) {}
68 
69  virtual ~VisitorImpl() {}
70 
71  void traverseDebugInfo();
72 
73 private:
74  void onVariableSizeValue(uint64_t U, unsigned Size);
75 };
76 
77 // Making the visior instantiations extern and explicit in the cpp file. This
78 // prevents them from being instantiated in every compile unit that uses the
79 // visitors.
80 extern template class VisitorImpl<DWARFYAML::Data>;
81 extern template class VisitorImpl<const DWARFYAML::Data>;
82 
83 class Visitor : public VisitorImpl<Data> {
84 public:
85  Visitor(Data &DI) : VisitorImpl<Data>(DI) {}
86 };
87 
89 public:
90  ConstVisitor(const Data &DI) : VisitorImpl<const Data>(DI) {}
91 };
92 
93 } // namespace DWARFYAML
94 } // namespace llvm
95 
96 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
virtual void onForm(const AttributeAbbrev &AttAbbrev, const FormValue &Value)
Definition: DWARFVisitor.h:51
virtual void onValue(const int64_t S, const bool LEB=false)
Definition: DWARFVisitor.h:61
virtual void onValue(const uint16_t U)
Definition: DWARFVisitor.h:58
virtual void onStartDIE(const Unit &CU, const Entry &DIE)
Definition: DWARFVisitor.h:49
virtual void onForm(AttributeAbbrev &AttAbbrev, FormValue &Value)
Definition: DWARFVisitor.h:42
virtual void onStartDIE(Unit &CU, Entry &DIE)
Definition: DWARFVisitor.h:40
virtual void onEndDIE(const Unit &CU, const Entry &DIE)
Definition: DWARFVisitor.h:50
virtual void onValue(const uint64_t U, const bool LEB=false)
Definition: DWARFVisitor.h:60
virtual void onValue(const StringRef String)
Definition: DWARFVisitor.h:62
A structured debug information entry.
Definition: DIE.h:700
virtual void onStartCompileUnit(const Unit &CU)
Const Visitor Functions.
Definition: DWARFVisitor.h:47
A class to visits DWARFYAML Compile Units and DIEs in preorder.
Definition: DWARFVisitor.h:32
virtual void onValue(const uint8_t U)
Value visitors.
Definition: DWARFVisitor.h:57
virtual void onEndDIE(Unit &CU, Entry &DIE)
Definition: DWARFVisitor.h:41
This file contains constants used for implementing Dwarf debug support.
ConstVisitor(const Data &DI)
Definition: DWARFVisitor.h:90
uint32_t Size
Definition: Profile.cpp:46
virtual void onStartCompileUnit(Unit &CU)
Visitor Functions.
Definition: DWARFVisitor.h:38
virtual void onValue(const uint32_t U)
Definition: DWARFVisitor.h:59
virtual void onEndCompileUnit(Unit &CU)
Definition: DWARFVisitor.h:39
virtual void onValue(const MemoryBufferRef MBR)
Definition: DWARFVisitor.h:63
aarch64 promote const
LLVM Value Representation.
Definition: Value.h:73
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
virtual void onEndCompileUnit(const Unit &CU)
Definition: DWARFVisitor.h:48