[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBTypeNameSpecifier.cpp
blob895f697756598373b47bbff376e803dec6eacd2b
1 //===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #include "lldb/API/SBTypeNameSpecifier.h"
11 #include "SBReproducerPrivate.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBType.h"
16 #include "lldb/DataFormatters/DataVisualization.h"
18 using namespace lldb;
19 using namespace lldb_private;
21 SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {
22 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeNameSpecifier);
25 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
26 : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
27 LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool), name,
28 is_regex);
30 if (name == nullptr || (*name) == 0)
31 m_opaque_sp.reset();
34 SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() {
35 LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType), type);
37 if (type.IsValid())
38 m_opaque_sp = TypeNameSpecifierImplSP(
39 new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
42 SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs)
43 : m_opaque_sp(rhs.m_opaque_sp) {
44 LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier,
45 (const lldb::SBTypeNameSpecifier &), rhs);
48 SBTypeNameSpecifier::~SBTypeNameSpecifier() {}
50 bool SBTypeNameSpecifier::IsValid() const {
51 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid);
52 return this->operator bool();
54 SBTypeNameSpecifier::operator bool() const {
55 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, operator bool);
57 return m_opaque_sp.get() != nullptr;
60 const char *SBTypeNameSpecifier::GetName() {
61 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeNameSpecifier, GetName);
63 if (!IsValid())
64 return nullptr;
66 return m_opaque_sp->GetName();
69 SBType SBTypeNameSpecifier::GetType() {
70 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeNameSpecifier, GetType);
72 if (!IsValid())
73 return LLDB_RECORD_RESULT(SBType());
74 lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
75 if (c_type.IsValid())
76 return LLDB_RECORD_RESULT(SBType(c_type));
77 return LLDB_RECORD_RESULT(SBType());
80 bool SBTypeNameSpecifier::IsRegex() {
81 LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeNameSpecifier, IsRegex);
83 if (!IsValid())
84 return false;
86 return m_opaque_sp->IsRegex();
89 bool SBTypeNameSpecifier::GetDescription(
90 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
91 LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, GetDescription,
92 (lldb::SBStream &, lldb::DescriptionLevel), description,
93 description_level);
95 if (!IsValid())
96 return false;
97 description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
98 IsRegex() ? "regex" : "plain");
99 return true;
102 lldb::SBTypeNameSpecifier &SBTypeNameSpecifier::
103 operator=(const lldb::SBTypeNameSpecifier &rhs) {
104 LLDB_RECORD_METHOD(
105 lldb::SBTypeNameSpecifier &,
106 SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs);
108 if (this != &rhs) {
109 m_opaque_sp = rhs.m_opaque_sp;
111 return LLDB_RECORD_RESULT(*this);
114 bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) {
115 LLDB_RECORD_METHOD(
116 bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs);
118 if (!IsValid())
119 return !rhs.IsValid();
120 return m_opaque_sp == rhs.m_opaque_sp;
123 bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) {
124 LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, IsEqualTo,
125 (lldb::SBTypeNameSpecifier &), rhs);
127 if (!IsValid())
128 return !rhs.IsValid();
130 if (IsRegex() != rhs.IsRegex())
131 return false;
132 if (GetName() == nullptr || rhs.GetName() == nullptr)
133 return false;
135 return (strcmp(GetName(), rhs.GetName()) == 0);
138 bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) {
139 LLDB_RECORD_METHOD(
140 bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs);
142 if (!IsValid())
143 return !rhs.IsValid();
144 return m_opaque_sp != rhs.m_opaque_sp;
147 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
148 return m_opaque_sp;
151 void SBTypeNameSpecifier::SetSP(
152 const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
153 m_opaque_sp = type_namespec_sp;
156 SBTypeNameSpecifier::SBTypeNameSpecifier(
157 const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
158 : m_opaque_sp(type_namespec_sp) {}
160 namespace lldb_private {
161 namespace repro {
163 template <>
164 void RegisterMethods<SBTypeNameSpecifier>(Registry &R) {
165 LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, ());
166 LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool));
167 LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType));
168 LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier,
169 (const lldb::SBTypeNameSpecifier &));
170 LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, IsValid, ());
171 LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ());
172 LLDB_REGISTER_METHOD(const char *, SBTypeNameSpecifier, GetName, ());
173 LLDB_REGISTER_METHOD(lldb::SBType, SBTypeNameSpecifier, GetType, ());
174 LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsRegex, ());
175 LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, GetDescription,
176 (lldb::SBStream &, lldb::DescriptionLevel));
177 LLDB_REGISTER_METHOD(
178 lldb::SBTypeNameSpecifier &,
179 SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &));
180 LLDB_REGISTER_METHOD(
181 bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &));
182 LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsEqualTo,
183 (lldb::SBTypeNameSpecifier &));
184 LLDB_REGISTER_METHOD(
185 bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &));