Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/ValueObjectList.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- ValueObjectList.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/ValueObjectList.h"
10
11
#include "lldb/Core/ValueObject.h"
12
#include "lldb/Utility/ConstString.h"
13
14
#include <utility>
15
16
using namespace lldb;
17
using namespace lldb_private;
18
19
0
const ValueObjectList &ValueObjectList::operator=(const ValueObjectList &rhs) {
20
0
  if (this != &rhs)
21
0
    m_value_objects = rhs.m_value_objects;
22
0
  return *this;
23
0
}
24
25
521
void ValueObjectList::Append(const ValueObjectSP &val_obj_sp) {
26
521
  m_value_objects.push_back(val_obj_sp);
27
521
}
28
29
0
void ValueObjectList::Append(const ValueObjectList &valobj_list) {
30
0
  std::copy(valobj_list.m_value_objects.begin(), // source begin
31
0
            valobj_list.m_value_objects.end(),   // source end
32
0
            back_inserter(m_value_objects));     // destination
33
0
}
34
35
6.46k
size_t ValueObjectList::GetSize() const { return m_value_objects.size(); }
36
37
1.93k
void ValueObjectList::Resize(size_t size) { m_value_objects.resize(size); }
38
39
11.8k
lldb::ValueObjectSP ValueObjectList::GetValueObjectAtIndex(size_t idx) {
40
11.8k
  lldb::ValueObjectSP valobj_sp;
41
11.8k
  if (idx < m_value_objects.size())
42
9.92k
    valobj_sp = m_value_objects[idx];
43
11.8k
  return valobj_sp;
44
11.8k
}
45
46
0
lldb::ValueObjectSP ValueObjectList::RemoveValueObjectAtIndex(size_t idx) {
47
0
  lldb::ValueObjectSP valobj_sp;
48
0
  if (idx < m_value_objects.size()) {
49
0
    valobj_sp = m_value_objects[idx];
50
0
    m_value_objects.erase(m_value_objects.begin() + idx);
51
0
  }
52
0
  return valobj_sp;
53
0
}
54
55
void ValueObjectList::SetValueObjectAtIndex(size_t idx,
56
6.42k
                                            const ValueObjectSP &valobj_sp) {
57
6.42k
  if (idx >= m_value_objects.size())
58
0
    m_value_objects.resize(idx + 1);
59
6.42k
  m_value_objects[idx] = valobj_sp;
60
6.42k
}
61
62
0
ValueObjectSP ValueObjectList::FindValueObjectByValueName(const char *name) {
63
0
  ConstString name_const_str(name);
64
0
  ValueObjectSP val_obj_sp;
65
0
  collection::iterator pos, end = m_value_objects.end();
66
0
  for (pos = m_value_objects.begin(); pos != end; ++pos) {
67
0
    ValueObject *valobj = (*pos).get();
68
0
    if (valobj && valobj->GetName() == name_const_str) {
69
0
      val_obj_sp = *pos;
70
0
      break;
71
0
    }
72
0
  }
73
0
  return val_obj_sp;
74
0
}
75
76
0
ValueObjectSP ValueObjectList::FindValueObjectByUID(lldb::user_id_t uid) {
77
0
  ValueObjectSP valobj_sp;
78
0
  collection::iterator pos, end = m_value_objects.end();
79
80
0
  for (pos = m_value_objects.begin(); pos != end; ++pos) {
81
    // Watch out for NULL objects in our list as the list might get resized to
82
    // a specific size and lazily filled in
83
0
    ValueObject *valobj = (*pos).get();
84
0
    if (valobj && valobj->GetID() == uid) {
85
0
      valobj_sp = *pos;
86
0
      break;
87
0
    }
88
0
  }
89
0
  return valobj_sp;
90
0
}
91
92
ValueObjectSP
93
0
ValueObjectList::FindValueObjectByPointer(ValueObject *find_valobj) {
94
0
  ValueObjectSP valobj_sp;
95
0
  collection::iterator pos, end = m_value_objects.end();
96
97
0
  for (pos = m_value_objects.begin(); pos != end; ++pos) {
98
0
    ValueObject *valobj = (*pos).get();
99
0
    if (valobj && valobj == find_valobj) {
100
0
      valobj_sp = *pos;
101
0
      break;
102
0
    }
103
0
  }
104
0
  return valobj_sp;
105
0
}
106
107
0
void ValueObjectList::Swap(ValueObjectList &value_object_list) {
108
0
  m_value_objects.swap(value_object_list.m_value_objects);
109
0
}