LLDB mainline
TypeList.cpp
Go to the documentation of this file.
1//===-- TypeList.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 <vector>
10
11#include "llvm/Support/FormattedStream.h"
12#include "llvm/Support/raw_ostream.h"
13
16#include "lldb/Symbol/Type.h"
18
19using namespace lldb;
20using namespace lldb_private;
21
23
24// Destructor
25TypeList::~TypeList() = default;
26
27void TypeList::Insert(const TypeSP &type_sp) {
28 // Just push each type on the back for now. We will worry about uniquing
29 // later
30 if (type_sp)
31 m_types.push_back(type_sp);
32}
33
34void TypeList::Clear() { m_types.clear(); }
35
36uint32_t TypeList::GetSize() const { return m_types.size(); }
37
38// GetTypeAtIndex isn't used a lot for large type lists, currently only for
39// type lists that are returned for "image dump -t TYPENAME" commands and other
40// simple symbol queries that grab the first result...
41
43 iterator pos, end;
44 uint32_t i = idx;
45 assert(i < GetSize() && "Accessing past the end of a TypeList");
46 for (pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
47 if (i == 0)
48 return *pos;
49 --i;
50 }
51 return TypeSP();
52}
53
55 std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const {
56 for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
57 if (!callback(*pos))
58 break;
59 }
60}
61
63 std::function<bool(lldb::TypeSP &type_sp)> const &callback) {
64 for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
65 if (!callback(*pos))
66 break;
67 }
68}
69
70void TypeList::Dump(Stream *s, bool show_context) {
71 for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
72 if (Type *t = pos->get())
73 t->Dump(s, show_context);
74}
A stream class that can stream formatted output to a file.
Definition Stream.h:28
uint32_t GetSize() const
Definition TypeList.cpp:36
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition TypeList.cpp:54
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition TypeList.cpp:42
collection::iterator iterator
Definition TypeList.h:50
void Dump(Stream *s, bool show_context)
Definition TypeList.cpp:70
void Insert(const lldb::TypeSP &type)
Definition TypeList.cpp:27
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Type > TypeSP