LLDB  mainline
SBTypeNameSpecifier.cpp
Go to the documentation of this file.
1 //===-- SBTypeNameSpecifier.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 
12 #include "lldb/API/SBStream.h"
13 #include "lldb/API/SBType.h"
14 
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
22 }
23 
24 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
25  : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
26  LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool), name,
27  is_regex);
28 
29  if (name == nullptr || (*name) == 0)
30  m_opaque_sp.reset();
31 }
32 
35 
36  if (type.IsValid())
37  m_opaque_sp = TypeNameSpecifierImplSP(
38  new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
39 }
40 
42  : m_opaque_sp(rhs.m_opaque_sp) {
44  (const lldb::SBTypeNameSpecifier &), rhs);
45 }
46 
48 
51  return this->operator bool();
52 }
53 SBTypeNameSpecifier::operator bool() const {
55 
56  return m_opaque_sp.get() != nullptr;
57 }
58 
61 
62  if (!IsValid())
63  return nullptr;
64 
65  return m_opaque_sp->GetName();
66 }
67 
70 
71  if (!IsValid())
72  return LLDB_RECORD_RESULT(SBType());
73  lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
74  if (c_type.IsValid())
75  return LLDB_RECORD_RESULT(SBType(c_type));
76  return LLDB_RECORD_RESULT(SBType());
77 }
78 
81 
82  if (!IsValid())
83  return false;
84 
85  return m_opaque_sp->IsRegex();
86 }
87 
89  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
91  (lldb::SBStream &, lldb::DescriptionLevel), description,
92  description_level);
93 
94  if (!IsValid())
95  return false;
96  description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
97  IsRegex() ? "regex" : "plain");
98  return true;
99 }
100 
105  SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs);
106 
107  if (this != &rhs) {
108  m_opaque_sp = rhs.m_opaque_sp;
109  }
110  return LLDB_RECORD_RESULT(*this);
111 }
112 
115  bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs);
116 
117  if (!IsValid())
118  return !rhs.IsValid();
119  return m_opaque_sp == rhs.m_opaque_sp;
120 }
121 
124  (lldb::SBTypeNameSpecifier &), rhs);
125 
126  if (!IsValid())
127  return !rhs.IsValid();
128 
129  if (IsRegex() != rhs.IsRegex())
130  return false;
131  if (GetName() == nullptr || rhs.GetName() == nullptr)
132  return false;
133 
134  return (strcmp(GetName(), rhs.GetName()) == 0);
135 }
136 
139  bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs);
140 
141  if (!IsValid())
142  return !rhs.IsValid();
143  return m_opaque_sp != rhs.m_opaque_sp;
144 }
145 
146 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
147  return m_opaque_sp;
148 }
149 
151  const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
152  m_opaque_sp = type_namespec_sp;
153 }
154 
156  const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
157  : m_opaque_sp(type_namespec_sp) {}
158 
159 namespace lldb_private {
160 namespace repro {
161 
162 template <>
165  LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool));
168  (const lldb::SBTypeNameSpecifier &));
170  LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ());
173  LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsRegex, ());
174  LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, GetDescription,
178  SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &));
180  bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &));
181  LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsEqualTo,
184  bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &));
185 }
186 
187 }
188 }
lldb::SBTypeNameSpecifier::operator==
bool operator==(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:113
lldb::SBTypeNameSpecifier
Definition: SBTypeNameSpecifier.h:17
lldb::SBStream::Printf
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:69
lldb::SBType::m_opaque_sp
lldb::TypeImplSP m_opaque_sp
Definition: SBType.h:223
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_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_REGISTER_METHOD_CONST
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:98
lldb::SBTypeNameSpecifier::SBTypeNameSpecifier
SBTypeNameSpecifier()
Definition: SBTypeNameSpecifier.cpp:20
SBReproducerPrivate.h
lldb_private::TypeNameSpecifierImpl
Definition: FormatClasses.h:106
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
lldb::SBType
class LLDB_API SBType
Definition: SBDefines.h:79
lldb::SBTypeNameSpecifier::operator!=
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:137
lldb_private::repro::RegisterMethods< SBTypeNameSpecifier >
void RegisterMethods< SBTypeNameSpecifier >(Registry &R)
Definition: SBTypeNameSpecifier.cpp:163
SBStream.h
lldb::SBTypeNameSpecifier::m_opaque_sp
lldb::TypeNameSpecifierImplSP m_opaque_sp
Definition: SBTypeNameSpecifier.h:58
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
lldb::SBTypeNameSpecifier::SetSP
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
Definition: SBTypeNameSpecifier.cpp:150
lldb::SBTypeNameSpecifier::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTypeNameSpecifier.cpp:88
GetName
static llvm::StringRef GetName(XcodeSDK::Type type)
Definition: XcodeSDK.cpp:21
lldb::SBTypeNameSpecifier::operator=
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:102
lldb::SBTypeNameSpecifier::IsRegex
bool IsRegex()
Definition: SBTypeNameSpecifier.cpp:79
lldb::SBTypeNameSpecifier::GetName
const char * GetName()
Definition: SBTypeNameSpecifier.cpp:59
SBTypeNameSpecifier.h
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:72
lldb::SBType
Definition: SBType.h:104
SBType.h
lldb::SBTypeNameSpecifier::GetType
SBType GetType()
Definition: SBTypeNameSpecifier.cpp:68
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
DataVisualization.h
lldb::SBTypeNameSpecifier::~SBTypeNameSpecifier
~SBTypeNameSpecifier()
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBTypeNameSpecifier::IsValid
bool IsValid() const
Definition: SBTypeNameSpecifier.cpp:49
lldb::SBType::IsValid
bool IsValid() const
Definition: SBType.cpp:109
lldb::SBStream
Definition: SBStream.h:18
lldb::SBTypeNameSpecifier::IsEqualTo
bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:122
lldb
Definition: SBAddress.h:15
lldb::SBTypeNameSpecifier::GetSP
lldb::TypeNameSpecifierImplSP GetSP()
Definition: SBTypeNameSpecifier.cpp:146
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93