annotate lldb/source/Core/SourceLocationSpec.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===-- SourceLocationSpec.cpp --------------------------------------------===//
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "lldb/Core/SourceLocationSpec.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "lldb/Utility/StreamString.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 using namespace lldb;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 using namespace lldb_private;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 llvm::Optional<uint16_t> column,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 bool check_inlines, bool exact_match)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 : m_declaration(file_spec, line,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 column.getValueOr(LLDB_INVALID_COLUMN_NUMBER)),
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 m_check_inlines(check_inlines), m_exact_match(exact_match) {}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 bool SourceLocationSpec::operator!() const { return !operator bool(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 bool SourceLocationSpec::operator==(const SourceLocationSpec &rhs) const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 return m_declaration == rhs.m_declaration &&
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 m_check_inlines == rhs.GetCheckInlines() &&
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 m_exact_match == rhs.GetExactMatch();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 bool SourceLocationSpec::operator!=(const SourceLocationSpec &rhs) const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 return !(*this == rhs);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 bool SourceLocationSpec::operator<(const SourceLocationSpec &rhs) const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 return SourceLocationSpec::Compare(*this, rhs) < 0;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 Stream &lldb_private::operator<<(Stream &s, const SourceLocationSpec &loc) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 loc.Dump(s);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 return s;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 int SourceLocationSpec::Compare(const SourceLocationSpec &lhs,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 const SourceLocationSpec &rhs) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 return Declaration::Compare(lhs.m_declaration, rhs.m_declaration);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 bool SourceLocationSpec::Equal(const SourceLocationSpec &lhs,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 const SourceLocationSpec &rhs, bool full) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 return full ? lhs == rhs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 : (lhs.GetFileSpec() == rhs.GetFileSpec() &&
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 lhs.GetLine() == rhs.GetLine());
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 void SourceLocationSpec::Dump(Stream &s) const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 s << "check inlines = " << llvm::toStringRef(m_check_inlines);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 s << ", exact match = " << llvm::toStringRef(m_exact_match);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 m_declaration.Dump(&s, true);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 std::string SourceLocationSpec::GetString() const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 StreamString ss;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Dump(ss);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 return ss.GetString().str();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 llvm::Optional<uint32_t> SourceLocationSpec::GetLine() const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 uint32_t line = m_declaration.GetLine();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 return llvm::None;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 return line;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 llvm::Optional<uint16_t> SourceLocationSpec::GetColumn() const {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 uint16_t column = m_declaration.GetColumn();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if (column == LLDB_INVALID_COLUMN_NUMBER)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 return llvm::None;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 return column;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }