/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/SourceLocationSpec.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- SourceLocationSpec.cpp --------------------------------------------===// |
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 | | #include "lldb/Core/SourceLocationSpec.h" |
10 | | #include "lldb/Utility/StreamString.h" |
11 | | #include "llvm/ADT/StringExtras.h" |
12 | | #include <optional> |
13 | | |
14 | | using namespace lldb; |
15 | | using namespace lldb_private; |
16 | | |
17 | | SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line, |
18 | | std::optional<uint16_t> column, |
19 | | bool check_inlines, bool exact_match) |
20 | 6.16k | : m_declaration(file_spec, line, |
21 | 6.16k | column.value_or(LLDB_INVALID_COLUMN_NUMBER)), |
22 | 6.16k | m_check_inlines(check_inlines), m_exact_match(exact_match) {} |
23 | | |
24 | 1.16k | SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); } |
25 | | |
26 | 1.16k | bool SourceLocationSpec::operator!() const { return !operator bool(); } |
27 | | |
28 | 7 | bool SourceLocationSpec::operator==(const SourceLocationSpec &rhs) const { |
29 | 7 | return m_declaration == rhs.m_declaration && |
30 | 7 | m_check_inlines == rhs.GetCheckInlines()3 && |
31 | 7 | m_exact_match == rhs.GetExactMatch()2 ; |
32 | 7 | } |
33 | | |
34 | 0 | bool SourceLocationSpec::operator!=(const SourceLocationSpec &rhs) const { |
35 | 0 | return !(*this == rhs); |
36 | 0 | } |
37 | | |
38 | 0 | bool SourceLocationSpec::operator<(const SourceLocationSpec &rhs) const { |
39 | 0 | return SourceLocationSpec::Compare(*this, rhs) < 0; |
40 | 0 | } |
41 | | |
42 | 0 | Stream &lldb_private::operator<<(Stream &s, const SourceLocationSpec &loc) { |
43 | 0 | loc.Dump(s); |
44 | 0 | return s; |
45 | 0 | } |
46 | | |
47 | | int SourceLocationSpec::Compare(const SourceLocationSpec &lhs, |
48 | 26 | const SourceLocationSpec &rhs) { |
49 | 26 | return Declaration::Compare(lhs.m_declaration, rhs.m_declaration); |
50 | 26 | } |
51 | | |
52 | | bool SourceLocationSpec::Equal(const SourceLocationSpec &lhs, |
53 | 14 | const SourceLocationSpec &rhs, bool full) { |
54 | 14 | return full ? lhs == rhs7 |
55 | 14 | : (7 lhs.GetFileSpec() == rhs.GetFileSpec()7 && |
56 | 7 | lhs.GetLine() == rhs.GetLine()5 ); |
57 | 14 | } |
58 | | |
59 | 2 | void SourceLocationSpec::Dump(Stream &s) const { |
60 | 2 | s << "check inlines = " << llvm::toStringRef(m_check_inlines); |
61 | 2 | s << ", exact match = " << llvm::toStringRef(m_exact_match); |
62 | 2 | m_declaration.Dump(&s, true); |
63 | 2 | } |
64 | | |
65 | 2 | std::string SourceLocationSpec::GetString() const { |
66 | 2 | StreamString ss; |
67 | 2 | Dump(ss); |
68 | 2 | return ss.GetString().str(); |
69 | 2 | } |
70 | | |
71 | 125k | std::optional<uint32_t> SourceLocationSpec::GetLine() const { |
72 | 125k | uint32_t line = m_declaration.GetLine(); |
73 | 125k | if (line == 0 || line == 125k LLDB_INVALID_LINE_NUMBER125k ) |
74 | 34 | return std::nullopt; |
75 | 125k | return line; |
76 | 125k | } |
77 | | |
78 | 120k | std::optional<uint16_t> SourceLocationSpec::GetColumn() const { |
79 | 120k | uint16_t column = m_declaration.GetColumn(); |
80 | 120k | if (column == LLDB_INVALID_COLUMN_NUMBER) |
81 | 118k | return std::nullopt; |
82 | 1.18k | return column; |
83 | 120k | } |