Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 1 | //===-- DebugMacros.cpp -----------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/Symbol/DebugMacros.h" |
| 10 | |
| 11 | #include "lldb/Symbol/CompileUnit.h" |
| 12 | |
| 13 | using namespace lldb_private; |
| 14 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 15 | DebugMacroEntry::DebugMacroEntry(EntryType type, uint32_t line, |
| 16 | uint32_t debug_line_file_idx, const char *str) |
| 17 | : m_type(type), m_line(line), m_debug_line_file_idx(debug_line_file_idx), |
| 18 | m_str(str) {} |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 19 | |
| 20 | DebugMacroEntry::DebugMacroEntry(EntryType type, |
| 21 | const DebugMacrosSP &debug_macros_sp) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 22 | : m_type(type), m_line(0), m_debug_line_file_idx(0), |
| 23 | m_debug_macros_sp(debug_macros_sp) {} |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 24 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 25 | const FileSpec &DebugMacroEntry::GetFileSpec(CompileUnit *comp_unit) const { |
| 26 | return comp_unit->GetSupportFiles().GetFileSpecAtIndex(m_debug_line_file_idx); |
| 27 | } |
| 28 | |
| 29 | DebugMacroEntry DebugMacroEntry::CreateDefineEntry(uint32_t line, |
| 30 | const char *str) { |
| 31 | return DebugMacroEntry(DebugMacroEntry::DEFINE, line, 0, str); |
| 32 | } |
| 33 | |
| 34 | DebugMacroEntry DebugMacroEntry::CreateUndefEntry(uint32_t line, |
| 35 | const char *str) { |
| 36 | return DebugMacroEntry(DebugMacroEntry::UNDEF, line, 0, str); |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | DebugMacroEntry |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 40 | DebugMacroEntry::CreateStartFileEntry(uint32_t line, |
| 41 | uint32_t debug_line_file_idx) { |
| 42 | return DebugMacroEntry(DebugMacroEntry::START_FILE, line, debug_line_file_idx, |
| 43 | nullptr); |
| 44 | } |
| 45 | |
| 46 | DebugMacroEntry DebugMacroEntry::CreateEndFileEntry() { |
| 47 | return DebugMacroEntry(DebugMacroEntry::END_FILE, 0, 0, nullptr); |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | DebugMacroEntry |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 51 | DebugMacroEntry::CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp) { |
| 52 | return DebugMacroEntry(DebugMacroEntry::INDIRECT, debug_macros_sp); |
Siva Chandra | d8335e9 | 2015-12-16 00:22:08 +0000 | [diff] [blame] | 53 | } |