LLDB mainline
SourceLocationSpec.cpp
Go to the documentation of this file.
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
11#include <optional>
12
13using namespace lldb;
14using namespace lldb_private;
15
17 std::optional<uint16_t> column,
18 bool check_inlines, bool exact_match)
19 : m_declaration(file_spec, line,
20 column.value_or(LLDB_INVALID_COLUMN_NUMBER)),
21 m_check_inlines(check_inlines), m_exact_match(exact_match) {}
22
23SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
24
25bool SourceLocationSpec::operator!() const { return !operator bool(); }
26
28 return m_declaration == rhs.m_declaration &&
31}
32
34 return !(*this == rhs);
35}
36
38 return SourceLocationSpec::Compare(*this, rhs) < 0;
39}
40
42 loc.Dump(s);
43 return s;
44}
45
47 const SourceLocationSpec &rhs) {
49}
50
52 const SourceLocationSpec &rhs, bool full) {
53 return full ? lhs == rhs
54 : (lhs.GetFileSpec() == rhs.GetFileSpec() &&
55 lhs.GetLine() == rhs.GetLine());
56}
57
59 s << "check inlines = " << llvm::toStringRef(m_check_inlines);
60 s << ", exact match = " << llvm::toStringRef(m_exact_match);
61 m_declaration.Dump(&s, true);
62}
63
64std::string SourceLocationSpec::GetString() const {
65 StreamString ss;
66 Dump(ss);
67 return ss.GetString().str();
68}
69
70std::optional<uint32_t> SourceLocationSpec::GetLine() const {
72 if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
73 return std::nullopt;
74 return line;
75}
76
77std::optional<uint16_t> SourceLocationSpec::GetColumn() const {
79 if (column == LLDB_INVALID_COLUMN_NUMBER)
80 return std::nullopt;
81 return column;
82}
uint32_t GetLine() const
Get accessor for the declaration line number.
Definition: Declaration.h:120
uint16_t GetColumn() const
Get accessor for the declaration column number.
Definition: Declaration.h:127
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
static int Compare(const Declaration &lhs, const Declaration &rhs)
Compare two declaration objects.
Definition: Declaration.cpp:58
A file utility class.
Definition: FileSpec.h:56
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
std::optional< uint32_t > GetLine() const
static bool Equal(const SourceLocationSpec &lhs, const SourceLocationSpec &rhs, bool full)
bool operator!=(const SourceLocationSpec &rhs) const
Not equal to operator.
bool operator<(const SourceLocationSpec &rhs) const
Less than to operator.
bool m_check_inlines
Tells if the resolver should look in inlined declaration.
std::optional< uint16_t > GetColumn() const
bool operator!() const
Logical NOT operator.
bool operator==(const SourceLocationSpec &rhs) const
Equal to operator.
void Dump(Stream &s) const
Dump this object to a Stream.
bool m_exact_match
Tells if the resolver should look for an exact match.
static int Compare(const SourceLocationSpec &lhs, const SourceLocationSpec &rhs)
Compare two SourceLocationSpec objects.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:86
#define LLDB_INVALID_COLUMN_NUMBER
Definition: lldb-defines.h:87
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
Definition: SBAddress.h:15