1 //===-- DebugMacros.cpp -----------------------------------------*- 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 #include "lldb/Symbol/DebugMacros.h"
11 
12 #include "lldb/Symbol/CompileUnit.h"
13 
14 using namespace lldb_private;
15 
16 DebugMacroEntry::DebugMacroEntry(EntryType type,
17                                  uint32_t line,
18                                  uint32_t debug_line_file_idx,
19                                  const char *str)
20     : m_type(type),
21       m_line(line),
22       m_debug_line_file_idx(debug_line_file_idx),
23       m_str(str)
24 { }
25 
26 DebugMacroEntry::DebugMacroEntry(EntryType type,
27                                  const DebugMacrosSP &debug_macros_sp)
28     : m_type(type), m_line(0), m_debug_line_file_idx(0), m_debug_macros_sp(debug_macros_sp)
29 { }
30 
31 const FileSpec&
32 DebugMacroEntry::GetFileSpec(CompileUnit *comp_unit) const
33 {
34     return comp_unit->GetSupportFiles().GetFileSpecAtIndex(m_debug_line_file_idx);
35 }
36 
37 DebugMacroEntry
38 DebugMacroEntry::CreateDefineEntry(uint32_t line, const char *str)
39 {
40     return DebugMacroEntry(DebugMacroEntry::DEFINE, line, 0, str);
41 }
42 
43 DebugMacroEntry
44 DebugMacroEntry::CreateUndefEntry(uint32_t line, const char *str)
45 {
46     return DebugMacroEntry(DebugMacroEntry::UNDEF, line, 0, str);
47 }
48 
49 DebugMacroEntry
50 DebugMacroEntry::CreateStartFileEntry(uint32_t line, uint32_t debug_line_file_idx)
51 {
52     return DebugMacroEntry(DebugMacroEntry::START_FILE, line, debug_line_file_idx, nullptr);
53 }
54 
55 DebugMacroEntry
56 DebugMacroEntry::CreateEndFileEntry()
57 {
58     return DebugMacroEntry(DebugMacroEntry::END_FILE, 0, 0, nullptr);
59 }
60 
61 DebugMacroEntry
62 DebugMacroEntry::CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp)
63 {
64     return DebugMacroEntry(DebugMacroEntry::INDIRECT, debug_macros_sp);
65 }
66