]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/DebugMacros.h
MFV r304732.
[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/lldb-private.h"
21 #include "lldb/Core/ConstString.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 {
31 public:
32     enum EntryType
33     {
34         INVALID,
35         DEFINE,
36         UNDEF,
37         START_FILE,
38         END_FILE,
39         INDIRECT
40     };
41
42 public:
43     static DebugMacroEntry
44     CreateDefineEntry(uint32_t line, const char *str);
45
46     static DebugMacroEntry
47     CreateUndefEntry(uint32_t line, const char *str);
48
49     static DebugMacroEntry
50     CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx);
51
52     static DebugMacroEntry
53     CreateEndFileEntry();
54
55     static DebugMacroEntry
56     CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
57
58     DebugMacroEntry() : m_type(INVALID) { }
59
60     ~DebugMacroEntry() = default;
61
62     EntryType
63     GetType() const
64     {
65         return m_type;
66     }
67
68     uint64_t
69     GetLineNumber() const
70     {
71         return m_line;
72     }
73
74     ConstString
75     GetMacroString() const
76     {
77         return m_str;
78     }
79
80     const FileSpec& GetFileSpec(CompileUnit *comp_unit) const;
81
82     DebugMacros *
83     GetIndirectDebugMacros() const
84     {
85         return m_debug_macros_sp.get();
86     }
87
88 private:
89     DebugMacroEntry(EntryType type,
90                     uint32_t line,
91                     uint32_t debug_line_file_idx,
92                     const char *str);
93
94     DebugMacroEntry(EntryType type,
95                     const DebugMacrosSP &debug_macros_sp);
96
97     EntryType m_type:3;
98     uint32_t m_line:29;
99     uint32_t m_debug_line_file_idx;
100     ConstString m_str;
101     DebugMacrosSP m_debug_macros_sp;
102 };
103
104 class DebugMacros
105 {
106 public:
107     DebugMacros() = default;
108
109     ~DebugMacros() = default;
110
111     void
112     AddMacroEntry(const DebugMacroEntry &entry)
113     {
114         m_macro_entries.push_back(entry);
115     }
116
117     size_t
118     GetNumMacroEntries() const
119     {
120         return m_macro_entries.size();
121     }
122
123     DebugMacroEntry
124     GetMacroEntryAtIndex(const size_t index) const
125     {
126         if (index < m_macro_entries.size())
127             return m_macro_entries[index];
128         else
129             return DebugMacroEntry();
130     }
131
132 private:
133     DISALLOW_COPY_AND_ASSIGN(DebugMacros);
134
135     std::vector<DebugMacroEntry> m_macro_entries;
136 };
137
138 } // namespace lldb_private
139
140 #endif // liblldb_DebugMacros_h_