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