Coverage Report

Created: 2022-01-18 06:27

/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
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
158k
      m_check_inlines(check_inlines), m_exact_match(exact_match) {}
21
22
1.59k
SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
23
24
1.59k
bool SourceLocationSpec::operator!() const { return !operator bool(); }
25
26
7
bool SourceLocationSpec::operator==(const SourceLocationSpec &rhs) const {
27
7
  return m_declaration == rhs.m_declaration &&
28
7
         
m_check_inlines == rhs.GetCheckInlines()3
&&
29
7
         
m_exact_match == rhs.GetExactMatch()2
;
30
7
}
31
32
0
bool SourceLocationSpec::operator!=(const SourceLocationSpec &rhs) const {
33
0
  return !(*this == rhs);
34
0
}
35
36
0
bool SourceLocationSpec::operator<(const SourceLocationSpec &rhs) const {
37
0
  return SourceLocationSpec::Compare(*this, rhs) < 0;
38
0
}
39
40
0
Stream &lldb_private::operator<<(Stream &s, const SourceLocationSpec &loc) {
41
0
  loc.Dump(s);
42
0
  return s;
43
0
}
44
45
int SourceLocationSpec::Compare(const SourceLocationSpec &lhs,
46
26
                                const SourceLocationSpec &rhs) {
47
26
  return Declaration::Compare(lhs.m_declaration, rhs.m_declaration);
48
26
}
49
50
bool SourceLocationSpec::Equal(const SourceLocationSpec &lhs,
51
14
                               const SourceLocationSpec &rhs, bool full) {
52
14
  return full ? 
lhs == rhs7
53
14
              : 
(7
lhs.GetFileSpec() == rhs.GetFileSpec()7
&&
54
7
                 
lhs.GetLine() == rhs.GetLine()5
);
55
14
}
56
57
2
void SourceLocationSpec::Dump(Stream &s) const {
58
2
  s << "check inlines = " << llvm::toStringRef(m_check_inlines);
59
2
  s << ", exact match = " << llvm::toStringRef(m_exact_match);
60
2
  m_declaration.Dump(&s, true);
61
2
}
62
63
2
std::string SourceLocationSpec::GetString() const {
64
2
  StreamString ss;
65
2
  Dump(ss);
66
2
  return ss.GetString().str();
67
2
}
68
69
321k
llvm::Optional<uint32_t> SourceLocationSpec::GetLine() const {
70
321k
  uint32_t line = m_declaration.GetLine();
71
321k
  if (line == 0 || 
line == 321k
LLDB_INVALID_LINE_NUMBER321k
)
72
34
    return llvm::None;
73
321k
  return line;
74
321k
}
75
76
314k
llvm::Optional<uint16_t> SourceLocationSpec::GetColumn() const {
77
314k
  uint16_t column = m_declaration.GetColumn();
78
314k
  if (column == LLDB_INVALID_COLUMN_NUMBER)
79
311k
    return llvm::None;
80
3.00k
  return column;
81
314k
}