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 
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 
21 
22 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
23  : SBTypeNameSpecifier(name, is_regex ? eFormatterMatchRegex
25  LLDB_INSTRUMENT_VA(this, name, is_regex);
26 }
27 
29  FormatterMatchType match_type)
30  : m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) {
31  LLDB_INSTRUMENT_VA(this, name, match_type);
32 
33  if (name == nullptr || (*name) == 0)
34  m_opaque_sp.reset();
35 }
36 
38  LLDB_INSTRUMENT_VA(this, type);
39 
40  if (type.IsValid())
41  m_opaque_sp = TypeNameSpecifierImplSP(
42  new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
43 }
44 
46  : m_opaque_sp(rhs.m_opaque_sp) {
47  LLDB_INSTRUMENT_VA(this, rhs);
48 }
49 
51 
53  LLDB_INSTRUMENT_VA(this);
54  return this->operator bool();
55 }
56 SBTypeNameSpecifier::operator bool() const {
57  LLDB_INSTRUMENT_VA(this);
58 
59  return m_opaque_sp.get() != nullptr;
60 }
61 
63  LLDB_INSTRUMENT_VA(this);
64 
65  if (!IsValid())
66  return nullptr;
67 
68  return m_opaque_sp->GetName();
69 }
70 
72  LLDB_INSTRUMENT_VA(this);
73 
74  if (!IsValid())
75  return SBType();
76  lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
77  if (c_type.IsValid())
78  return SBType(c_type);
79  return SBType();
80 }
81 
83  LLDB_INSTRUMENT_VA(this);
84  if (!IsValid())
85  return eFormatterMatchExact;
86  return m_opaque_sp->GetMatchType();
87 }
88 
90  LLDB_INSTRUMENT_VA(this);
91 
92  if (!IsValid())
93  return false;
94 
95  return m_opaque_sp->GetMatchType() == eFormatterMatchRegex;
96 }
97 
99  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
100  LLDB_INSTRUMENT_VA(this, description, description_level);
101 
102  if (!IsValid())
103  return false;
104  description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
105  IsRegex() ? "regex" : "plain");
106  return true;
107 }
108 
111  LLDB_INSTRUMENT_VA(this, rhs);
112 
113  if (this != &rhs) {
114  m_opaque_sp = rhs.m_opaque_sp;
115  }
116  return *this;
117 }
118 
120  LLDB_INSTRUMENT_VA(this, rhs);
121 
122  if (!IsValid())
123  return !rhs.IsValid();
124  return m_opaque_sp == rhs.m_opaque_sp;
125 }
126 
128  LLDB_INSTRUMENT_VA(this, rhs);
129 
130  if (!IsValid())
131  return !rhs.IsValid();
132 
133  if (GetMatchType() != rhs.GetMatchType())
134  return false;
135  if (GetName() == nullptr || rhs.GetName() == nullptr)
136  return false;
137 
138  return (strcmp(GetName(), rhs.GetName()) == 0);
139 }
140 
142  LLDB_INSTRUMENT_VA(this, rhs);
143 
144  if (!IsValid())
145  return !rhs.IsValid();
146  return m_opaque_sp != rhs.m_opaque_sp;
147 }
148 
149 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
150  return m_opaque_sp;
151 }
152 
154  const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
155  m_opaque_sp = type_namespec_sp;
156 }
157 
159  const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
160  : m_opaque_sp(type_namespec_sp) {}
Instrumentation.h
lldb::SBTypeNameSpecifier::operator==
bool operator==(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:119
lldb::SBTypeNameSpecifier
Definition: SBTypeNameSpecifier.h:17
lldb::SBStream::Printf
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:70
lldb::SBType::m_opaque_sp
lldb::TypeImplSP m_opaque_sp
Definition: SBType.h:227
lldb::FormatterMatchType
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.
Definition: lldb-enumerations.h:835
lldb::SBTypeNameSpecifier::SBTypeNameSpecifier
SBTypeNameSpecifier()
Definition: SBTypeNameSpecifier.cpp:20
lldb_private::TypeNameSpecifierImpl
Definition: FormatClasses.h:132
lldb::SBTypeNameSpecifier::GetMatchType
lldb::FormatterMatchType GetMatchType()
Definition: SBTypeNameSpecifier.cpp:82
lldb::SBType
class LLDB_API SBType
Definition: SBDefines.h:92
lldb::SBTypeNameSpecifier::operator!=
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:141
SBStream.h
lldb::SBTypeNameSpecifier::m_opaque_sp
lldb::TypeNameSpecifierImplSP m_opaque_sp
Definition: SBTypeNameSpecifier.h:63
bool
lldb::SBTypeNameSpecifier::SetSP
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
Definition: SBTypeNameSpecifier.cpp:153
lldb::SBTypeNameSpecifier::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTypeNameSpecifier.cpp:98
lldb::SBTypeNameSpecifier::operator=
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:110
lldb::SBTypeNameSpecifier::IsRegex
bool IsRegex()
Definition: SBTypeNameSpecifier.cpp:89
lldb::SBTypeNameSpecifier::GetName
const char * GetName()
Definition: SBTypeNameSpecifier.cpp:62
lldb::eFormatterMatchExact
@ eFormatterMatchExact
Definition: lldb-enumerations.h:836
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:71
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_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::SBTypeNameSpecifier::IsValid
bool IsValid() const
Definition: SBTypeNameSpecifier.cpp:52
lldb::SBType::IsValid
bool IsValid() const
Definition: SBType.cpp:108
lldb::SBStream
Definition: SBStream.h:18
lldb::SBTypeNameSpecifier::IsEqualTo
bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:127
lldb
Definition: SBAddress.h:15
lldb::SBTypeNameSpecifier::GetSP
lldb::TypeNameSpecifierImplSP GetSP()
Definition: SBTypeNameSpecifier.cpp:149
lldb::eFormatterMatchRegex
@ eFormatterMatchRegex
Definition: lldb-enumerations.h:837
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207