Coverage Report

Created: 2021-04-24 07:00

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