1 //===-- SBSymbolContextList.cpp -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBSymbolContextList.h"
11 #include "lldb/API/SBStream.h"
12 #include "lldb/Symbol/SymbolContext.h"
13 #include "lldb/Utility/Instrumentation.h"
16 using namespace lldb_private
;
18 SBSymbolContextList::SBSymbolContextList()
19 : m_opaque_up(new SymbolContextList()) {
20 LLDB_INSTRUMENT_VA(this);
23 SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList
&rhs
) {
24 LLDB_INSTRUMENT_VA(this, rhs
);
26 m_opaque_up
= clone(rhs
.m_opaque_up
);
29 SBSymbolContextList::~SBSymbolContextList() = default;
31 const SBSymbolContextList
&SBSymbolContextList::
32 operator=(const SBSymbolContextList
&rhs
) {
33 LLDB_INSTRUMENT_VA(this, rhs
);
36 m_opaque_up
= clone(rhs
.m_opaque_up
);
40 uint32_t SBSymbolContextList::GetSize() const {
41 LLDB_INSTRUMENT_VA(this);
44 return m_opaque_up
->GetSize();
48 SBSymbolContext
SBSymbolContextList::GetContextAtIndex(uint32_t idx
) {
49 LLDB_INSTRUMENT_VA(this, idx
);
51 SBSymbolContext sb_sc
;
54 if (m_opaque_up
->GetContextAtIndex(idx
, sc
))
60 void SBSymbolContextList::Clear() {
61 LLDB_INSTRUMENT_VA(this);
67 void SBSymbolContextList::Append(SBSymbolContext
&sc
) {
68 LLDB_INSTRUMENT_VA(this, sc
);
70 if (sc
.IsValid() && m_opaque_up
.get())
71 m_opaque_up
->Append(*sc
);
74 void SBSymbolContextList::Append(SBSymbolContextList
&sc_list
) {
75 LLDB_INSTRUMENT_VA(this, sc_list
);
77 if (sc_list
.IsValid() && m_opaque_up
.get())
78 m_opaque_up
->Append(*sc_list
);
81 bool SBSymbolContextList::IsValid() const {
82 LLDB_INSTRUMENT_VA(this);
83 return this->operator bool();
85 SBSymbolContextList::operator bool() const {
86 LLDB_INSTRUMENT_VA(this);
88 return m_opaque_up
!= nullptr;
91 lldb_private::SymbolContextList
*SBSymbolContextList::operator->() const {
92 return m_opaque_up
.get();
95 lldb_private::SymbolContextList
&SBSymbolContextList::operator*() const {
96 assert(m_opaque_up
.get());
100 bool SBSymbolContextList::GetDescription(lldb::SBStream
&description
) {
101 LLDB_INSTRUMENT_VA(this, description
);
103 Stream
&strm
= description
.ref();
105 m_opaque_up
->GetDescription(&strm
, lldb::eDescriptionLevelFull
, nullptr);