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
12
13#include "lldb/API/SBStream.h"
14#include "lldb/API/SBType.h"
15
17
18using namespace lldb;
19using namespace lldb_private;
20
22
23SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
26 LLDB_INSTRUMENT_VA(this, name, is_regex);
27}
28
30 FormatterMatchType match_type)
31 : m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) {
32 LLDB_INSTRUMENT_VA(this, name, match_type);
33
34 if (name == nullptr || (*name) == 0)
35 m_opaque_sp.reset();
36}
37
39 LLDB_INSTRUMENT_VA(this, type);
40
41 if (type.IsValid())
42 m_opaque_sp = std::make_shared<TypeNameSpecifierImpl>(
43 type.m_opaque_sp->GetCompilerType(true));
44}
45
50
52
55 return this->operator bool();
56}
57SBTypeNameSpecifier::operator bool() const {
59
60 return m_opaque_sp.get() != nullptr;
61}
62
65
66 if (!IsValid())
67 return nullptr;
68
69 return StringPool::GetSystemPool().Intern(m_opaque_sp->GetName());
70}
71
74
75 if (!IsValid())
76 return SBType();
77 lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
78 if (c_type.IsValid())
79 return SBType(c_type);
80 return SBType();
81}
82
89
92
93 if (!IsValid())
94 return false;
95
96 return m_opaque_sp->GetMatchType() == eFormatterMatchRegex;
97}
98
100 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
101 LLDB_INSTRUMENT_VA(this, description, description_level);
102
104 const char *match_type_str =
105 (match_type == eFormatterMatchExact ? "plain"
106 : match_type == eFormatterMatchRegex ? "regex"
107 : "callback");
108 if (!IsValid())
109 return false;
110 description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), match_type_str);
111 return true;
112}
113
116 LLDB_INSTRUMENT_VA(this, rhs);
117
118 if (this != &rhs) {
120 }
121 return *this;
122}
123
125 LLDB_INSTRUMENT_VA(this, rhs);
126
127 if (!IsValid())
128 return !rhs.IsValid();
129 return m_opaque_sp == rhs.m_opaque_sp;
130}
131
133 LLDB_INSTRUMENT_VA(this, rhs);
134
135 if (!IsValid())
136 return !rhs.IsValid();
137
138 if (GetMatchType() != rhs.GetMatchType())
139 return false;
140 if (GetName() == nullptr || rhs.GetName() == nullptr)
141 return false;
142
143 return (strcmp(GetName(), rhs.GetName()) == 0);
144}
145
147 LLDB_INSTRUMENT_VA(this, rhs);
148
149 if (!IsValid())
150 return rhs.IsValid();
151 return m_opaque_sp != rhs.m_opaque_sp;
152}
153
157
159 const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
160 m_opaque_sp = type_namespec_sp;
161}
162
164 const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
165 : m_opaque_sp(type_namespec_sp) {}
#define LLDB_INSTRUMENT_VA(...)
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
bool operator==(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeNameSpecifierImplSP GetSP()
bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeNameSpecifierImplSP m_opaque_sp
lldb::FormatterMatchType GetMatchType()
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeImplSP m_opaque_sp
Definition SBType.h:279
bool IsValid() const
Definition SBType.cpp:114
Generic representation of a type in a programming language.
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
static StringPoolRef GetSystemPool()
The system pool. Only valid between Initialize and Terminate.
A class that represents a running process on the host machine.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::TypeNameSpecifierImpl > TypeNameSpecifierImplSP
class LLDB_API SBType
Definition SBDefines.h:124
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.