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 
12 using namespace lldb;
13 using namespace lldb_private;
14 
15 SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line,
16  llvm::Optional<uint16_t> column,
17  bool check_inlines, bool exact_match)
18  : m_declaration(file_spec, line,
19  column.getValueOr(LLDB_INVALID_COLUMN_NUMBER)),
20  m_check_inlines(check_inlines), m_exact_match(exact_match) {}
21 
22 SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
23 
24 bool SourceLocationSpec::operator!() const { return !operator bool(); }
25 
27  return m_declaration == rhs.m_declaration &&
30 }
31 
33  return !(*this == rhs);
34 }
35 
37  return SourceLocationSpec::Compare(*this, rhs) < 0;
38 }
39 
41  loc.Dump(s);
42  return s;
43 }
44 
46  const SourceLocationSpec &rhs) {
48 }
49 
51  const SourceLocationSpec &rhs, bool full) {
52  return full ? lhs == rhs
53  : (lhs.GetFileSpec() == rhs.GetFileSpec() &&
54  lhs.GetLine() == rhs.GetLine());
55 }
56 
58  s << "check inlines = " << llvm::toStringRef(m_check_inlines);
59  s << ", exact match = " << llvm::toStringRef(m_exact_match);
60  m_declaration.Dump(&s, true);
61 }
62 
64  StreamString ss;
65  Dump(ss);
66  return ss.GetString().str();
67 }
68 
69 llvm::Optional<uint32_t> SourceLocationSpec::GetLine() const {
71  if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
72  return llvm::None;
73  return line;
74 }
75 
76 llvm::Optional<uint16_t> SourceLocationSpec::GetColumn() const {
77  uint16_t column = m_declaration.GetColumn();
78  if (column == LLDB_INVALID_COLUMN_NUMBER)
79  return llvm::None;
80  return column;
81 }
lldb_private::SourceLocationSpec::GetFileSpec
FileSpec GetFileSpec() const
Definition: SourceLocationSpec.h:166
lldb_private::SourceLocationSpec::m_exact_match
bool m_exact_match
Tells if the resolver should look for an exact match.
Definition: SourceLocationSpec.h:181
lldb_private::SourceLocationSpec
Definition: SourceLocationSpec.h:27
LLDB_INVALID_COLUMN_NUMBER
#define LLDB_INVALID_COLUMN_NUMBER
Definition: lldb-defines.h:99
lldb_private::SourceLocationSpec::Equal
static bool Equal(const SourceLocationSpec &lhs, const SourceLocationSpec &rhs, bool full)
Definition: SourceLocationSpec.cpp:50
lldb_private::Declaration::GetColumn
uint16_t GetColumn() const
Get accessor for the declaration column number.
Definition: Declaration.h:127
lldb_private::Stream
Definition: Stream.h:28
lldb_private::SourceLocationSpec::GetString
std::string GetString() const
Definition: SourceLocationSpec.cpp:63
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::SourceLocationSpec::operator==
bool operator==(const SourceLocationSpec &rhs) const
Equal to operator.
Definition: SourceLocationSpec.cpp:26
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::Declaration::Dump
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
lldb_private::SourceLocationSpec::operator<
bool operator<(const SourceLocationSpec &rhs) const
Less than to operator.
Definition: SourceLocationSpec.cpp:36
lldb_private::SourceLocationSpec::Dump
void Dump(Stream &s) const
Dump this object to a Stream.
Definition: SourceLocationSpec.cpp:57
SourceLocationSpec.h
StreamString.h
lldb_private::StreamString
Definition: StreamString.h:23
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:39
LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_LINE_NUMBER
Definition: lldb-defines.h:98
lldb_private::Declaration::GetLine
uint32_t GetLine() const
Get accessor for the declaration line number.
Definition: Declaration.h:120
uint32_t
lldb_private::operator<<
Stream & operator<<(Stream &s, const SourceLocationSpec &loc)
Dump a SourceLocationSpec object to a stream.
Definition: SourceLocationSpec.cpp:40
uint16_t
lldb_private::SourceLocationSpec::m_declaration
Declaration m_declaration
Definition: SourceLocationSpec.h:177
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::SourceLocationSpec::GetExactMatch
bool GetExactMatch() const
Definition: SourceLocationSpec.h:174
lldb_private::SourceLocationSpec::GetColumn
llvm::Optional< uint16_t > GetColumn() const
Definition: SourceLocationSpec.cpp:76
lldb_private::SourceLocationSpec::Compare
static int Compare(const SourceLocationSpec &lhs, const SourceLocationSpec &rhs)
Compare two SourceLocationSpec objects.
Definition: SourceLocationSpec.cpp:45
lldb_private::SourceLocationSpec::operator!
bool operator!() const
Logical NOT operator.
Definition: SourceLocationSpec.cpp:24
lldb_private::SourceLocationSpec::GetCheckInlines
bool GetCheckInlines() const
Definition: SourceLocationSpec.h:172
lldb_private::Declaration::Compare
static int Compare(const Declaration &lhs, const Declaration &rhs)
Compare two declaration objects.
Definition: Declaration.cpp:58
lldb_private::SourceLocationSpec::m_check_inlines
bool m_check_inlines
Tells if the resolver should look in inlined declaration.
Definition: SourceLocationSpec.h:179
lldb
Definition: SBAddress.h:15
lldb_private::SourceLocationSpec::operator!=
bool operator!=(const SourceLocationSpec &rhs) const
Not equal to operator.
Definition: SourceLocationSpec.cpp:32
lldb_private::SourceLocationSpec::GetLine
llvm::Optional< uint32_t > GetLine() const
Definition: SourceLocationSpec.cpp:69