LLDB  mainline
SBTypeEnumMember.cpp
Go to the documentation of this file.
1 //===-- SBTypeEnumMember.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 
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBType.h"
16 #include "lldb/Symbol/Type.h"
17 #include "lldb/Utility/Stream.h"
18 
19 #include <memory>
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
26 }
27 
29 
31  const lldb::TypeEnumMemberImplSP &enum_member_sp)
32  : m_opaque_sp(enum_member_sp) {}
33 
35  : m_opaque_sp() {
37  rhs);
38 
40 }
41 
45  SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs);
46 
47  if (this != &rhs)
49  return LLDB_RECORD_RESULT(*this);
50 }
51 
54  return this->operator bool();
55 }
56 SBTypeEnumMember::operator bool() const {
58 
59  return m_opaque_sp.get();
60 }
61 
64 
65  if (m_opaque_sp.get())
66  return m_opaque_sp->GetName().GetCString();
67  return nullptr;
68 }
69 
72 
73  if (m_opaque_sp.get())
74  return m_opaque_sp->GetValueAsSigned();
75  return 0;
76 }
77 
80 
81  if (m_opaque_sp.get())
82  return m_opaque_sp->GetValueAsUnsigned();
83  return 0;
84 }
85 
88 
89  SBType sb_type;
90  if (m_opaque_sp.get()) {
91  sb_type.SetSP(m_opaque_sp->GetIntegerType());
92  }
93  return LLDB_RECORD_RESULT(sb_type);
94 }
95 
97  m_opaque_sp.reset(type_member_impl);
98 }
99 
101  if (m_opaque_sp.get() == nullptr)
102  m_opaque_sp = std::make_shared<TypeEnumMemberImpl>();
103  return *m_opaque_sp.get();
104 }
105 
107  return *m_opaque_sp.get();
108 }
109 
111  : m_opaque_up(new TypeEnumMemberListImpl()) {
113 }
114 
116  : m_opaque_up(new TypeEnumMemberListImpl()) {
118  (const lldb::SBTypeEnumMemberList &), rhs);
119 
120  for (uint32_t i = 0,
121  rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
122  i < rhs_size; i++)
124 }
125 
128  return this->operator bool();
129 }
130 SBTypeEnumMemberList::operator bool() const {
132 
133  return (m_opaque_up != nullptr);
134 }
135 
141  rhs);
142 
143  if (this != &rhs) {
144  m_opaque_up = std::make_unique<TypeEnumMemberListImpl>();
145  for (uint32_t i = 0,
146  rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
147  i < rhs_size; i++)
148  Append(
149  const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
150  }
151  return LLDB_RECORD_RESULT(*this);
152 }
153 
156  (lldb::SBTypeEnumMember), enum_member);
157 
158  if (enum_member.IsValid())
159  m_opaque_up->Append(enum_member.m_opaque_sp);
160 }
161 
166 
167  if (m_opaque_up)
168  return LLDB_RECORD_RESULT(
169  SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index)));
171 }
172 
175 
176  return m_opaque_up->GetSize();
177 }
178 
180 
182  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
184  (lldb::SBStream &, lldb::DescriptionLevel), description,
185  description_level);
186 
187  Stream &strm = description.ref();
188 
189  if (m_opaque_sp.get()) {
190  if (m_opaque_sp->GetIntegerType()->GetDescription(strm,
191  description_level)) {
192  strm.Printf(" %s", m_opaque_sp->GetName().GetCString());
193  }
194  } else {
195  strm.PutCString("No value");
196  }
197  return true;
198 }
199 
200 namespace lldb_private {
201 namespace repro {
202 
203 template <>
207  (const lldb::SBTypeEnumMember &));
210  SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &));
211  LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, IsValid, ());
212  LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, operator bool, ());
213  LLDB_REGISTER_METHOD(const char *, SBTypeEnumMember, GetName, ());
214  LLDB_REGISTER_METHOD(int64_t, SBTypeEnumMember, GetValueAsSigned, ());
215  LLDB_REGISTER_METHOD(uint64_t, SBTypeEnumMember, GetValueAsUnsigned, ());
219  (const lldb::SBTypeEnumMemberList &));
220  LLDB_REGISTER_METHOD(bool, SBTypeEnumMemberList, IsValid, ());
221  LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMemberList, operator bool, ());
224  SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &));
228  GetTypeEnumMemberAtIndex, (uint32_t));
230  LLDB_REGISTER_METHOD(bool, SBTypeEnumMember, GetDescription,
232 }
233 
234 }
235 }
lldb::SBStream::ref
lldb_private::Stream & ref()
Definition: SBStream.cpp:178
lldb_private::TypeEnumMemberImpl
Definition: Type.h:472
SBDefines.h
lldb::SBTypeEnumMemberList
Definition: SBTypeEnumMember.h:57
LLDB_RECORD_RESULT
#define LLDB_RECORD_RESULT(Result)
Definition: ReproducerInstrumentation.h:211
LLDB_RECORD_METHOD_CONST_NO_ARGS
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:168
lldb::SBTypeEnumMember::IsValid
bool IsValid() const
Definition: SBTypeEnumMember.cpp:52
LLDB_RECORD_METHOD_NO_ARGS
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:165
LLDB_RECORD_CONSTRUCTOR_NO_ARGS
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
Definition: ReproducerInstrumentation.h:136
lldb::SBTypeEnumMemberList::m_opaque_up
std::unique_ptr< lldb_private::TypeEnumMemberListImpl > m_opaque_up
Definition: SBTypeEnumMember.h:78
LLDB_REGISTER_METHOD_CONST
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:98
lldb::SBTypeEnumMemberList::operator=
SBTypeEnumMemberList & operator=(const SBTypeEnumMemberList &rhs)
Definition: SBTypeEnumMember.cpp:137
SBTypeEnumMember.h
lldb_private::Stream
Definition: Stream.h:28
SBReproducerPrivate.h
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
R
#define R(base)
SBStream.h
lldb::SBTypeEnumMember::GetValueAsUnsigned
uint64_t GetValueAsUnsigned()
Definition: SBTypeEnumMember.cpp:78
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
lldb::SBTypeEnumMemberList::IsValid
bool IsValid()
Definition: SBTypeEnumMember.cpp:126
Utils.h
lldb::SBTypeEnumMember::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTypeEnumMember.cpp:181
lldb::SBTypeEnumMemberList::GetTypeEnumMemberAtIndex
SBTypeEnumMember GetTypeEnumMemberAtIndex(uint32_t index)
Definition: SBTypeEnumMember.cpp:163
GetName
static llvm::StringRef GetName(XcodeSDK::Type type)
Definition: XcodeSDK.cpp:21
Type.h
lldb::SBTypeEnumMember::GetName
const char * GetName()
Definition: SBTypeEnumMember.cpp:62
lldb::SBTypeEnumMember
class LLDB_API SBTypeEnumMember
Definition: SBDefines.h:81
lldb::SBTypeEnumMember::GetType
lldb::SBType GetType()
Definition: SBTypeEnumMember.cpp:86
lldb::SBTypeEnumMember::operator=
SBTypeEnumMember & operator=(const SBTypeEnumMember &rhs)
Definition: SBTypeEnumMember.cpp:42
CompilerType.h
lldb::SBType
Definition: SBType.h:104
SBType.h
lldb::SBTypeEnumMember::reset
void reset(lldb_private::TypeEnumMemberImpl *)
Definition: SBTypeEnumMember.cpp:96
LLDB_RECORD_CONSTRUCTOR
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
Definition: ReproducerInstrumentation.h:133
lldb_private::repro::Registry
The registry contains a unique mapping between functions and their ID.
Definition: ReproducerInstrumentation.h:517
lldb::SBTypeEnumMember::ref
lldb_private::TypeEnumMemberImpl & ref()
Definition: SBTypeEnumMember.cpp:100
lldb::SBTypeEnumMemberList::Append
void Append(SBTypeEnumMember entry)
Definition: SBTypeEnumMember.cpp:154
lldb::SBTypeEnumMember::SBTypeEnumMember
SBTypeEnumMember()
Definition: SBTypeEnumMember.cpp:24
lldb_private::TypeEnumMemberListImpl
Definition: Type.h:500
uint32_t
lldb::SBTypeEnumMemberList::~SBTypeEnumMemberList
~SBTypeEnumMemberList()
lldb::SBTypeEnumMemberList::SBTypeEnumMemberList
SBTypeEnumMemberList()
Definition: SBTypeEnumMember.cpp:110
lldb::SBTypeEnumMember::m_opaque_sp
lldb::TypeEnumMemberImplSP m_opaque_sp
Definition: SBTypeEnumMember.h:52
lldb::SBTypeEnumMemberList::GetSize
uint32_t GetSize()
Definition: SBTypeEnumMember.cpp:173
lldb::SBTypeEnumMember::GetValueAsSigned
int64_t GetValueAsSigned()
Definition: SBTypeEnumMember.cpp:70
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Stream.h
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb::SBStream
Definition: SBStream.h:18
lldb::SBTypeEnumMember::~SBTypeEnumMember
~SBTypeEnumMember()
lldb
Definition: SBAddress.h:15
lldb::SBType::SetSP
void SetSP(const lldb::TypeImplSP &type_impl_sp)
Definition: SBType.cpp:79
lldb::SBTypeEnumMember
Definition: SBTypeEnumMember.h:17
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::repro::RegisterMethods< SBTypeEnumMember >
void RegisterMethods< SBTypeEnumMember >(Registry &R)
Definition: SBTypeEnumMember.cpp:204
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93