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
42TypeSP TypeList::GetTypeAtIndex(uint32_t idx) const {
43 assert(idx < GetSize() && "Accessing past the end of a TypeList");
44
45 if (idx < m_types.size())
46 return m_types[idx];
47 return {};
48}
49
51 std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const {
52 for (const auto &type : m_types) {
53 if (!callback(type))
54 break;
55 }
56}
57
59 std::function<bool(lldb::TypeSP &type_sp)> const &callback) {
60 for (auto &type : m_types) {
61 if (!callback(type))
62 break;
63 }
64}
65
66void TypeList::Dump(Stream *s, bool show_context) {
67 for (auto &type : m_types)
68 if (type)
69 type->Dump(s, show_context);
70}
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:50
void Dump(Stream *s, bool show_context)
Definition TypeList.cpp:66
void Insert(const lldb::TypeSP &type)
Definition TypeList.cpp:27
lldb::TypeSP GetTypeAtIndex(uint32_t idx) const
Definition TypeList.cpp:42
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Type > TypeSP