[ARM] MVE integer min and max
[llvm-complete.git] / lib / ObjectYAML / DWARFVisitor.h
blob50e88aa7a26bf137d71360608c0b40e86dc8e376
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 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_OBJECTYAML_DWARFVISITOR_H
12 #define LLVM_OBJECTYAML_DWARFVISITOR_H
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/BinaryFormat/Dwarf.h"
16 #include "llvm/Support/MemoryBuffer.h"
18 namespace llvm {
20 namespace DWARFYAML {
22 struct Data;
23 struct Unit;
24 struct Entry;
25 struct FormValue;
26 struct AttributeAbbrev;
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:
34 T &DebugInfo;
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 /// @}
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 /// @}
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 /// @}
66 public:
67 VisitorImpl(T &DI) : DebugInfo(DI) {}
69 virtual ~VisitorImpl() {}
71 void traverseDebugInfo();
73 private:
74 void onVariableSizeValue(uint64_t U, unsigned Size);
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>;
83 class Visitor : public VisitorImpl<Data> {
84 public:
85 Visitor(Data &DI) : VisitorImpl<Data>(DI) {}
88 class ConstVisitor : public VisitorImpl<const Data> {
89 public:
90 ConstVisitor(const Data &DI) : VisitorImpl<const Data>(DI) {}
93 } // namespace DWARFYAML
94 } // namespace llvm
96 #endif