Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Symbol/DebugMacros.h
Line
Count
Source (jump to first uncovered line)
1
//===-- DebugMacros.h -------------------------------------------*- C++ -*-===//
2
//
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
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_SYMBOL_DEBUGMACROS_H
10
#define LLDB_SYMBOL_DEBUGMACROS_H
11
12
#include <memory>
13
#include <vector>
14
15
#include "lldb/Utility/ConstString.h"
16
#include "lldb/lldb-private.h"
17
18
namespace lldb_private {
19
20
class CompileUnit;
21
class DebugMacros;
22
typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
23
24
class DebugMacroEntry {
25
public:
26
  enum EntryType : uint8_t {
27
      INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT
28
  };
29
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
0
  DebugMacroEntry() : m_type(INVALID) {}
43
44
0
  ~DebugMacroEntry() = default;
45
46
0
  EntryType GetType() const { return static_cast<EntryType>(m_type); }
47
48
0
  uint64_t GetLineNumber() const { return m_line; }
49
50
0
  ConstString GetMacroString() const { return m_str; }
51
52
  const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
53
54
0
  DebugMacros *GetIndirectDebugMacros() const {
55
0
    return m_debug_macros_sp.get();
56
0
  }
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
  uint32_t 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
0
  DebugMacros() = default;
74
75
0
  ~DebugMacros() = default;
76
77
0
  void AddMacroEntry(const DebugMacroEntry &entry) {
78
0
    m_macro_entries.push_back(entry);
79
0
  }
80
81
0
  size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
82
83
0
  DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
84
0
    if (index < m_macro_entries.size())
85
0
      return m_macro_entries[index];
86
0
    else
87
0
      return DebugMacroEntry();
88
0
  }
89
90
private:
91
  DebugMacros(const DebugMacros &) = delete;
92
  const DebugMacros &operator=(const DebugMacros &) = delete;
93
94
  std::vector<DebugMacroEntry> m_macro_entries;
95
};
96
97
} // namespace lldb_private
98
99
#endif // LLDB_SYMBOL_DEBUGMACROS_H