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  : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
24  LLDB_INSTRUMENT_VA(this, name, is_regex);
25 
26  if (name == nullptr || (*name) == 0)
27  m_opaque_sp.reset();
28 }
29 
31  LLDB_INSTRUMENT_VA(this, type);
32 
33  if (type.IsValid())
34  m_opaque_sp = TypeNameSpecifierImplSP(
35  new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
36 }
37 
39  : m_opaque_sp(rhs.m_opaque_sp) {
40  LLDB_INSTRUMENT_VA(this, rhs);
41 }
42 
44 
46  LLDB_INSTRUMENT_VA(this);
47  return this->operator bool();
48 }
49 SBTypeNameSpecifier::operator bool() const {
50  LLDB_INSTRUMENT_VA(this);
51 
52  return m_opaque_sp.get() != nullptr;
53 }
54 
56  LLDB_INSTRUMENT_VA(this);
57 
58  if (!IsValid())
59  return nullptr;
60 
61  return m_opaque_sp->GetName();
62 }
63 
65  LLDB_INSTRUMENT_VA(this);
66 
67  if (!IsValid())
68  return SBType();
69  lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
70  if (c_type.IsValid())
71  return SBType(c_type);
72  return SBType();
73 }
74 
76  LLDB_INSTRUMENT_VA(this);
77 
78  if (!IsValid())
79  return false;
80 
81  return m_opaque_sp->IsRegex();
82 }
83 
85  lldb::SBStream &description, lldb::DescriptionLevel description_level) {
86  LLDB_INSTRUMENT_VA(this, description, description_level);
87 
88  if (!IsValid())
89  return false;
90  description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
91  IsRegex() ? "regex" : "plain");
92  return true;
93 }
94 
97  LLDB_INSTRUMENT_VA(this, rhs);
98 
99  if (this != &rhs) {
100  m_opaque_sp = rhs.m_opaque_sp;
101  }
102  return *this;
103 }
104 
106  LLDB_INSTRUMENT_VA(this, rhs);
107 
108  if (!IsValid())
109  return !rhs.IsValid();
110  return m_opaque_sp == rhs.m_opaque_sp;
111 }
112 
114  LLDB_INSTRUMENT_VA(this, rhs);
115 
116  if (!IsValid())
117  return !rhs.IsValid();
118 
119  if (IsRegex() != rhs.IsRegex())
120  return false;
121  if (GetName() == nullptr || rhs.GetName() == nullptr)
122  return false;
123 
124  return (strcmp(GetName(), rhs.GetName()) == 0);
125 }
126 
128  LLDB_INSTRUMENT_VA(this, rhs);
129 
130  if (!IsValid())
131  return !rhs.IsValid();
132  return m_opaque_sp != rhs.m_opaque_sp;
133 }
134 
135 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
136  return m_opaque_sp;
137 }
138 
140  const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
141  m_opaque_sp = type_namespec_sp;
142 }
143 
145  const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
146  : m_opaque_sp(type_namespec_sp) {}
Instrumentation.h
lldb::SBTypeNameSpecifier::operator==
bool operator==(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:105
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:225
lldb::SBTypeNameSpecifier::SBTypeNameSpecifier
SBTypeNameSpecifier()
Definition: SBTypeNameSpecifier.cpp:20
lldb_private::TypeNameSpecifierImpl
Definition: FormatClasses.h:106
lldb::SBType
class LLDB_API SBType
Definition: SBDefines.h:91
lldb::SBTypeNameSpecifier::operator!=
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:127
SBStream.h
lldb::SBTypeNameSpecifier::m_opaque_sp
lldb::TypeNameSpecifierImplSP m_opaque_sp
Definition: SBTypeNameSpecifier.h:58
lldb::SBTypeNameSpecifier::SetSP
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
Definition: SBTypeNameSpecifier.cpp:139
lldb::SBTypeNameSpecifier::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTypeNameSpecifier.cpp:84
lldb::SBTypeNameSpecifier::operator=
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
Definition: SBTypeNameSpecifier.cpp:96
lldb::SBTypeNameSpecifier::IsRegex
bool IsRegex()
Definition: SBTypeNameSpecifier.cpp:75
lldb::SBTypeNameSpecifier::GetName
const char * GetName()
Definition: SBTypeNameSpecifier.cpp:55
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:64
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:45
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:113
lldb
Definition: SBAddress.h:15
lldb::SBTypeNameSpecifier::GetSP
lldb::TypeNameSpecifierImplSP GetSP()
Definition: SBTypeNameSpecifier.cpp:135
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207