]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/DebugMacros.h
Update to Zstandard 1.3.8
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Symbol / DebugMacros.h
1 //===-- DebugMacros.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 liblldb_DebugMacros_h_
11 #define liblldb_DebugMacros_h_
12
13 // C Includes
14 // C++ Includes
15 #include <memory>
16 #include <vector>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/Utility/ConstString.h"
21 #include "lldb/lldb-private.h"
22
23 namespace lldb_private {
24
25 class CompileUnit;
26 class DebugMacros;
27 typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
28
29 class DebugMacroEntry {
30 public:
31   enum EntryType { INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT };
32
33 public:
34   static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
35
36   static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
37
38   static DebugMacroEntry CreateStartFileEntry(uint32_t line,
39                                               uint32_t debug_line_file_idx);
40
41   static DebugMacroEntry CreateEndFileEntry();
42
43   static DebugMacroEntry
44   CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
45
46   DebugMacroEntry() : m_type(INVALID) {}
47
48   ~DebugMacroEntry() = default;
49
50   EntryType GetType() const { return m_type; }
51
52   uint64_t GetLineNumber() const { return m_line; }
53
54   ConstString GetMacroString() const { return m_str; }
55
56   const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
57
58   DebugMacros *GetIndirectDebugMacros() const {
59     return m_debug_macros_sp.get();
60   }
61
62 private:
63   DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
64                   const char *str);
65
66   DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
67
68   EntryType m_type : 3;
69   uint32_t m_line : 29;
70   uint32_t m_debug_line_file_idx;
71   ConstString m_str;
72   DebugMacrosSP m_debug_macros_sp;
73 };
74
75 class DebugMacros {
76 public:
77   DebugMacros() = default;
78
79   ~DebugMacros() = default;
80
81   void AddMacroEntry(const DebugMacroEntry &entry) {
82     m_macro_entries.push_back(entry);
83   }
84
85   size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
86
87   DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
88     if (index < m_macro_entries.size())
89       return m_macro_entries[index];
90     else
91       return DebugMacroEntry();
92   }
93
94 private:
95   DISALLOW_COPY_AND_ASSIGN(DebugMacros);
96
97   std::vector<DebugMacroEntry> m_macro_entries;
98 };
99
100 } // namespace lldb_private
101
102 #endif // liblldb_DebugMacros_h_