LLDB  mainline
SBTypeNameSpecifier.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
9 
11 #include "SBReproducerPrivate.h"
12 
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBType.h"
15 
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
23 }
24 
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);
29 
30  if (name == NULL || (*name) == 0)
31  m_opaque_sp.reset();
32 }
33 
36 
37  if (type.IsValid())
38  m_opaque_sp = TypeNameSpecifierImplSP(
39  new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
40 }
41 
43  : m_opaque_sp(rhs.m_opaque_sp) {
45  (const lldb::SBTypeNameSpecifier &), rhs);
46 }
47 
49 
52  return this->operator bool();
53 }
54 SBTypeNameSpecifier::operator bool() const {
56 
57  return m_opaque_sp.get() != NULL;
58 }
59 
62 
63  if (!IsValid())
64  return NULL;
65 
66  return m_opaque_sp->GetName();
67 }
68 
71 
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());
78 }
79 
82 
83  if (!IsValid())
84  return false;
85 
86  return m_opaque_sp->IsRegex();
87 }
88 
90  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
92  (lldb::SBStream &, lldb::DescriptionLevel), description,
93  description_level);
94 
95  if (!IsValid())
96  return false;
97  description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
98  IsRegex() ? "regex" : "plain");
99  return true;
100 }
101 
106  SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs);
107 
108  if (this != &rhs) {
109  m_opaque_sp = rhs.m_opaque_sp;
110  }
111  return LLDB_RECORD_RESULT(*this);
112 }
113 
116  bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs);
117 
118  if (!IsValid())
119  return !rhs.IsValid();
120  return m_opaque_sp == rhs.m_opaque_sp;
121 }
122 
125  (lldb::SBTypeNameSpecifier &), rhs);
126 
127  if (!IsValid())
128  return !rhs.IsValid();
129 
130  if (IsRegex() != rhs.IsRegex())
131  return false;
132  if (GetName() == NULL || rhs.GetName() == NULL)
133  return false;
134 
135  return (strcmp(GetName(), rhs.GetName()) == 0);
136 }
137 
140  bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs);
141 
142  if (!IsValid())
143  return !rhs.IsValid();
144  return m_opaque_sp != rhs.m_opaque_sp;
145 }
146 
147 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
148  return m_opaque_sp;
149 }
150 
152  const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
153  m_opaque_sp = type_namespec_sp;
154 }
155 
157  const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
158  : m_opaque_sp(type_namespec_sp) {}
159 
160 namespace lldb_private {
161 namespace repro {
162 
163 template <>
166  LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool));
169  (const lldb::SBTypeNameSpecifier &));
171  LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ());
179  SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &));
181  bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &));
185  bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &));
186 }
187 
188 }
189 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs)
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:62
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
lldb::TypeNameSpecifierImplSP m_opaque_sp
bool operator==(lldb::SBTypeNameSpecifier &rhs)
class LLDB_API SBType
Definition: SBDefines.h:78
Definition: SBAddress.h:15
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
bool IsValid() const
Definition: SBType.cpp:108
lldb::TypeNameSpecifierImplSP GetSP()
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
lldb::TypeImplSP m_opaque_sp
Definition: SBType.h:216
#define LLDB_RECORD_RESULT(Result)
void RegisterMethods< SBTypeNameSpecifier >(Registry &R)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)