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 "llvm/ADT/StringExtras.h"
12#include <optional>
13
14using namespace lldb;
15using namespace lldb_private;
16
18 std::optional<uint16_t> column,
19 bool check_inlines, bool exact_match)
20 : m_declaration(file_spec, line,
21 column.value_or(LLDB_INVALID_COLUMN_NUMBER)),
22 m_check_inlines(check_inlines), m_exact_match(exact_match) {}
23
24SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
25
26bool SourceLocationSpec::operator!() const { return !operator bool(); }
27
29 return m_declaration == rhs.m_declaration &&
32}
33
35 return !(*this == rhs);
36}
37
39 return SourceLocationSpec::Compare(*this, rhs) < 0;
40}
41
43 loc.Dump(s);
44 return s;
45}
46
48 const SourceLocationSpec &rhs) {
50}
51
53 const SourceLocationSpec &rhs, bool full) {
54 return full ? lhs == rhs
55 : (lhs.GetFileSpec() == rhs.GetFileSpec() &&
56 lhs.GetLine() == rhs.GetLine());
57}
58
60 s << "check inlines = " << llvm::toStringRef(m_check_inlines);
61 s << ", exact match = " << llvm::toStringRef(m_exact_match);
62 m_declaration.Dump(&s, true);
63}
64
65std::string SourceLocationSpec::GetString() const {
66 StreamString ss;
67 Dump(ss);
68 return ss.GetString().str();
69}
70
71std::optional<uint32_t> SourceLocationSpec::GetLine() const {
72 uint32_t line = m_declaration.GetLine();
73 if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
74 return std::nullopt;
75 return line;
76}
77
78std::optional<uint16_t> SourceLocationSpec::GetColumn() const {
79 uint16_t column = m_declaration.GetColumn();
80 if (column == LLDB_INVALID_COLUMN_NUMBER)
81 return std::nullopt;
82 return column;
83}
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:94
#define LLDB_INVALID_COLUMN_NUMBER
Definition: lldb-defines.h:95
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Stream & operator<<(Stream &s, const Mangled &obj)
Definition: SBAddress.h:15