1*80814287SRaphael Isemann //===-- DebugMacros.cpp ---------------------------------------------------===//
2d8335e9aSSiva Chandra //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d8335e9aSSiva Chandra //
7d8335e9aSSiva Chandra //===----------------------------------------------------------------------===//
8d8335e9aSSiva Chandra
9d8335e9aSSiva Chandra #include "lldb/Symbol/DebugMacros.h"
10d8335e9aSSiva Chandra
11d8335e9aSSiva Chandra #include "lldb/Symbol/CompileUnit.h"
12d8335e9aSSiva Chandra
13d8335e9aSSiva Chandra using namespace lldb_private;
14d8335e9aSSiva Chandra
DebugMacroEntry(EntryType type,uint32_t line,uint32_t debug_line_file_idx,const char * str)15b9c1b51eSKate Stone DebugMacroEntry::DebugMacroEntry(EntryType type, uint32_t line,
16b9c1b51eSKate Stone uint32_t debug_line_file_idx, const char *str)
17b9c1b51eSKate Stone : m_type(type), m_line(line), m_debug_line_file_idx(debug_line_file_idx),
18b9c1b51eSKate Stone m_str(str) {}
19d8335e9aSSiva Chandra
DebugMacroEntry(EntryType type,const DebugMacrosSP & debug_macros_sp)20d8335e9aSSiva Chandra DebugMacroEntry::DebugMacroEntry(EntryType type,
21d8335e9aSSiva Chandra const DebugMacrosSP &debug_macros_sp)
22b9c1b51eSKate Stone : m_type(type), m_line(0), m_debug_line_file_idx(0),
23b9c1b51eSKate Stone m_debug_macros_sp(debug_macros_sp) {}
24d8335e9aSSiva Chandra
GetFileSpec(CompileUnit * comp_unit) const25b9c1b51eSKate Stone const FileSpec &DebugMacroEntry::GetFileSpec(CompileUnit *comp_unit) const {
26d8335e9aSSiva Chandra return comp_unit->GetSupportFiles().GetFileSpecAtIndex(m_debug_line_file_idx);
27d8335e9aSSiva Chandra }
28d8335e9aSSiva Chandra
CreateDefineEntry(uint32_t line,const char * str)29b9c1b51eSKate Stone DebugMacroEntry DebugMacroEntry::CreateDefineEntry(uint32_t line,
30b9c1b51eSKate Stone const char *str) {
31d8335e9aSSiva Chandra return DebugMacroEntry(DebugMacroEntry::DEFINE, line, 0, str);
32d8335e9aSSiva Chandra }
33d8335e9aSSiva Chandra
CreateUndefEntry(uint32_t line,const char * str)34b9c1b51eSKate Stone DebugMacroEntry DebugMacroEntry::CreateUndefEntry(uint32_t line,
35b9c1b51eSKate Stone const char *str) {
36d8335e9aSSiva Chandra return DebugMacroEntry(DebugMacroEntry::UNDEF, line, 0, str);
37d8335e9aSSiva Chandra }
38d8335e9aSSiva Chandra
39d8335e9aSSiva Chandra DebugMacroEntry
CreateStartFileEntry(uint32_t line,uint32_t debug_line_file_idx)40b9c1b51eSKate Stone DebugMacroEntry::CreateStartFileEntry(uint32_t line,
41b9c1b51eSKate Stone uint32_t debug_line_file_idx) {
42b9c1b51eSKate Stone return DebugMacroEntry(DebugMacroEntry::START_FILE, line, debug_line_file_idx,
43b9c1b51eSKate Stone nullptr);
44d8335e9aSSiva Chandra }
45d8335e9aSSiva Chandra
CreateEndFileEntry()46b9c1b51eSKate Stone DebugMacroEntry DebugMacroEntry::CreateEndFileEntry() {
47d8335e9aSSiva Chandra return DebugMacroEntry(DebugMacroEntry::END_FILE, 0, 0, nullptr);
48d8335e9aSSiva Chandra }
49d8335e9aSSiva Chandra
50d8335e9aSSiva Chandra DebugMacroEntry
CreateIndirectEntry(const DebugMacrosSP & debug_macros_sp)51b9c1b51eSKate Stone DebugMacroEntry::CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp) {
52d8335e9aSSiva Chandra return DebugMacroEntry(DebugMacroEntry::INDIRECT, debug_macros_sp);
53d8335e9aSSiva Chandra }
54