Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/Declaration.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- Declaration.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/Declaration.h"
10
#include "lldb/Utility/Stream.h"
11
12
using namespace lldb_private;
13
14
158
void Declaration::Dump(Stream *s, bool show_fullpaths) const {
15
158
  if (m_file) {
16
96
    *s << ", decl = ";
17
96
    if (show_fullpaths)
18
4
      *s << m_file;
19
92
    else
20
92
      *s << m_file.GetFilename();
21
96
    if (m_line > 0)
22
96
      s->Printf(":%u", m_line);
23
96
    if (m_column != LLDB_INVALID_COLUMN_NUMBER)
24
1
      s->Printf(":%u", m_column);
25
96
  } else {
26
62
    if (m_line > 0) {
27
4
      s->Printf(", line = %u", m_line);
28
4
      if (m_column != LLDB_INVALID_COLUMN_NUMBER)
29
0
        s->Printf(":%u", m_column);
30
58
    } else if (m_column != LLDB_INVALID_COLUMN_NUMBER)
31
0
      s->Printf(", column = %u", m_column);
32
62
  }
33
158
}
34
35
121
bool Declaration::DumpStopContext(Stream *s, bool show_fullpaths) const {
36
121
  if (m_file) {
37
103
    if (show_fullpaths)
38
63
      *s << m_file;
39
40
    else
40
40
      m_file.GetFilename().Dump(s);
41
42
103
    if (m_line > 0)
43
103
      s->Printf(":%u", m_line);
44
103
    if (m_column != LLDB_INVALID_COLUMN_NUMBER)
45
0
      s->Printf(":%u", m_column);
46
103
    return true;
47
103
  } else 
if (18
m_line > 018
) {
48
0
    s->Printf(" line %u", m_line);
49
0
    if (m_column != LLDB_INVALID_COLUMN_NUMBER)
50
0
      s->Printf(":%u", m_column);
51
0
    return true;
52
0
  }
53
18
  return false;
54
121
}
55
56
0
size_t Declaration::MemorySize() const { return sizeof(Declaration); }
57
58
26
int Declaration::Compare(const Declaration &a, const Declaration &b) {
59
26
  int result = FileSpec::Compare(a.m_file, b.m_file, true);
60
26
  if (result)
61
8
    return result;
62
18
  if (a.m_line < b.m_line)
63
4
    return -1;
64
14
  else if (a.m_line > b.m_line)
65
4
    return 1;
66
10
  if (a.m_column < b.m_column)
67
3
    return -1;
68
7
  else if (a.m_column > b.m_column)
69
3
    return 1;
70
4
  return 0;
71
10
}
72
73
105
bool Declaration::FileAndLineEqual(const Declaration &declaration) const {
74
105
  int file_compare = FileSpec::Compare(this->m_file, declaration.m_file, true);
75
105
  return file_compare == 0 && this->m_line == declaration.m_line;
76
105
}
77
78
38
bool lldb_private::operator==(const Declaration &lhs, const Declaration &rhs) {
79
38
  if (lhs.GetColumn() != rhs.GetColumn())
80
2
    return false;
81
82
36
  return lhs.GetLine() == rhs.GetLine() && lhs.GetFile() == rhs.GetFile();
83
38
}