[Lldb-commits] [lldb] r356993 - Remove the TypePair class
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 26 06:35:54 PDT 2019
Author: labath
Date: Tue Mar 26 06:35:54 2019
New Revision: 356993
URL: http://llvm.org/viewvc/llvm-project?rev=356993&view=rev
Log:
Remove the TypePair class
Summary:
After D59297, the TypePair class kind of lost its purpose as it was no
longer a "pair". This finishes the job started in that patch and deletes
the class altogether. All usages have been updated to use CompilerType
class directly.
Reviewers: clayborg, jingham, zturner
Subscribers: mehdi_amini, dexonsmith, jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D59414
Modified:
lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
lldb/trunk/include/lldb/Symbol/Type.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Symbol/Type.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?rev=356993&r1=356992&r2=356993&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Tue Mar 26 06:35:54 2019
@@ -122,14 +122,14 @@ public:
TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() {
if (type) {
m_type.m_type_name = type->GetName().GetStringRef();
- m_type.m_type_pair.SetType(type);
+ m_type.m_compiler_type = type->GetForwardCompilerType();
}
}
TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() {
if (type.IsValid()) {
m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
- m_type.m_type_pair.SetType(type);
+ m_type.m_compiler_type = type;
}
}
@@ -140,8 +140,8 @@ public:
}
CompilerType GetCompilerType() {
- if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetCompilerType();
+ if (m_type.m_compiler_type.IsValid())
+ return m_type.m_compiler_type;
return CompilerType();
}
@@ -149,11 +149,10 @@ public:
private:
bool m_is_regex;
- // this works better than TypeAndOrName because the latter only wraps a
- // TypeSP whereas TypePair can also be backed by a CompilerType
+ // TODO: Replace this with TypeAndOrName.
struct TypeOrName {
std::string m_type_name;
- TypePair m_type_pair;
+ CompilerType m_compiler_type;
};
TypeOrName m_type;
Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=356993&r1=356992&r2=356993&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Tue Mar 26 06:35:54 2019
@@ -237,81 +237,6 @@ protected:
bool ResolveClangType(ResolveState compiler_type_resolve_state);
};
-// these classes are used to back the SBType* objects
-
-// TODO: This class is just a wrapper around CompilerType. Delete it.
-class TypePair {
-public:
- TypePair() : compiler_type() {}
-
- TypePair(CompilerType type) : compiler_type(type) {}
-
- TypePair(lldb::TypeSP type) : compiler_type(type->GetForwardCompilerType()) {}
-
- bool IsValid() const { return compiler_type.IsValid(); }
-
- explicit operator bool() const { return IsValid(); }
-
- bool operator==(const TypePair &rhs) const {
- return compiler_type == rhs.compiler_type;
- }
-
- bool operator!=(const TypePair &rhs) const { return !(*this == rhs); }
-
- void Clear() { compiler_type.Clear(); }
-
- ConstString GetName() const {
- if (compiler_type)
- return compiler_type.GetTypeName();
- return ConstString();
- }
-
- ConstString GetDisplayTypeName() const {
- if (compiler_type)
- return compiler_type.GetDisplayTypeName();
- return ConstString();
- }
-
- void SetType(CompilerType type) {
- compiler_type = type;
- }
-
- void SetType(lldb::TypeSP type) {
- compiler_type = type->GetForwardCompilerType();
- }
-
- CompilerType GetCompilerType() const { return compiler_type; }
-
- CompilerType GetPointerType() const { return compiler_type.GetPointerType(); }
-
- CompilerType GetPointeeType() const { return compiler_type.GetPointeeType(); }
-
- CompilerType GetReferenceType() const {
- return compiler_type.GetLValueReferenceType();
- }
-
- CompilerType GetTypedefedType() const {
- return compiler_type.GetTypedefedType();
- }
-
- CompilerType GetDereferencedType() const {
- return compiler_type.GetNonReferenceType();
- }
-
- CompilerType GetUnqualifiedType() const {
- return compiler_type.GetFullyUnqualifiedType();
- }
-
- CompilerType GetCanonicalType() const {
- return compiler_type.GetCanonicalType();
- }
-
- TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); }
-
-protected:
- CompilerType compiler_type;
-};
-
// the two classes here are used by the public API as a backend to the SBType
// and SBTypeList classes
@@ -331,8 +256,6 @@ public:
TypeImpl(const CompilerType &compiler_type, const CompilerType &dynamic);
- TypeImpl(const TypePair &pair, const CompilerType &dynamic);
-
void SetType(const lldb::TypeSP &type_sp);
void SetType(const CompilerType &compiler_type);
@@ -341,8 +264,6 @@ public:
void SetType(const CompilerType &compiler_type, const CompilerType &dynamic);
- void SetType(const TypePair &pair, const CompilerType &dynamic);
-
TypeImpl &operator=(const TypeImpl &rhs);
bool operator==(const TypeImpl &rhs) const;
@@ -384,7 +305,7 @@ private:
bool CheckModule(lldb::ModuleSP &module_sp) const;
lldb::ModuleWP m_module_wp;
- TypePair m_static_type;
+ CompilerType m_static_type;
CompilerType m_dynamic_type;
};
@@ -476,22 +397,19 @@ protected:
class TypeAndOrName {
public:
- TypeAndOrName();
+ TypeAndOrName() = default;
TypeAndOrName(lldb::TypeSP &type_sp);
TypeAndOrName(const CompilerType &compiler_type);
TypeAndOrName(const char *type_str);
- TypeAndOrName(const TypeAndOrName &rhs);
TypeAndOrName(ConstString &type_const_string);
- TypeAndOrName &operator=(const TypeAndOrName &rhs);
-
bool operator==(const TypeAndOrName &other) const;
bool operator!=(const TypeAndOrName &other) const;
ConstString GetName() const;
- CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); }
+ CompilerType GetCompilerType() const { return m_compiler_type; }
void SetName(ConstString type_name);
@@ -514,7 +432,7 @@ public:
explicit operator bool() { return !IsEmpty(); }
private:
- TypePair m_type_pair;
+ CompilerType m_compiler_type;
ConstString m_type_name;
};
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=356993&r1=356992&r2=356993&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Tue Mar 26 06:35:54 2019
@@ -273,7 +273,6 @@ class TypeEnumMemberImpl;
class TypeEnumMemberListImpl;
class TypeFormatImpl;
class TypeNameSpecifierImpl;
-class TypePair;
class TypeValidatorImpl;
class UUID;
class UnixSignals;
Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=356993&r1=356992&r2=356993&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Mar 26 06:35:54 2019
@@ -690,32 +690,21 @@ ModuleSP Type::GetModule() {
return ModuleSP();
}
-TypeAndOrName::TypeAndOrName() : m_type_pair(), m_type_name() {}
-
-TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) : m_type_pair(in_type_sp) {
- if (in_type_sp)
+TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) {
+ if (in_type_sp) {
+ m_compiler_type = in_type_sp->GetForwardCompilerType();
m_type_name = in_type_sp->GetName();
+ }
}
TypeAndOrName::TypeAndOrName(const char *in_type_str)
: m_type_name(in_type_str) {}
-TypeAndOrName::TypeAndOrName(const TypeAndOrName &rhs)
- : m_type_pair(rhs.m_type_pair), m_type_name(rhs.m_type_name) {}
-
TypeAndOrName::TypeAndOrName(ConstString &in_type_const_string)
: m_type_name(in_type_const_string) {}
-TypeAndOrName &TypeAndOrName::operator=(const TypeAndOrName &rhs) {
- if (this != &rhs) {
- m_type_name = rhs.m_type_name;
- m_type_pair = rhs.m_type_pair;
- }
- return *this;
-}
-
bool TypeAndOrName::operator==(const TypeAndOrName &other) const {
- if (m_type_pair != other.m_type_pair)
+ if (m_compiler_type != other.m_compiler_type)
return false;
if (m_type_name != other.m_type_name)
return false;
@@ -729,8 +718,8 @@ bool TypeAndOrName::operator!=(const Typ
ConstString TypeAndOrName::GetName() const {
if (m_type_name)
return m_type_name;
- if (m_type_pair)
- return m_type_pair.GetName();
+ if (m_compiler_type)
+ return m_compiler_type.GetTypeName();
return ConstString("<invalid>");
}
@@ -743,30 +732,32 @@ void TypeAndOrName::SetName(const char *
}
void TypeAndOrName::SetTypeSP(lldb::TypeSP type_sp) {
- m_type_pair.SetType(type_sp);
- if (m_type_pair)
- m_type_name = m_type_pair.GetName();
+ if (type_sp) {
+ m_compiler_type = type_sp->GetForwardCompilerType();
+ m_type_name = type_sp->GetName();
+ } else
+ Clear();
}
void TypeAndOrName::SetCompilerType(CompilerType compiler_type) {
- m_type_pair.SetType(compiler_type);
- if (m_type_pair)
- m_type_name = m_type_pair.GetName();
+ m_compiler_type = compiler_type;
+ if (m_compiler_type)
+ m_type_name = m_compiler_type.GetTypeName();
}
bool TypeAndOrName::IsEmpty() const {
- return !((bool)m_type_name || (bool)m_type_pair);
+ return !((bool)m_type_name || (bool)m_compiler_type);
}
void TypeAndOrName::Clear() {
m_type_name.Clear();
- m_type_pair.Clear();
+ m_compiler_type.Clear();
}
bool TypeAndOrName::HasName() const { return (bool)m_type_name; }
bool TypeAndOrName::HasCompilerType() const {
- return m_type_pair.GetCompilerType().IsValid();
+ return m_compiler_type.IsValid();
}
TypeImpl::TypeImpl() : m_module_wp(), m_static_type(), m_dynamic_type() {}
@@ -786,7 +777,7 @@ TypeImpl::TypeImpl(const CompilerType &c
}
TypeImpl::TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic)
- : m_module_wp(), m_static_type(type_sp), m_dynamic_type(dynamic) {
+ : m_module_wp(), m_static_type(), m_dynamic_type(dynamic) {
SetType(type_sp, dynamic);
}
@@ -796,22 +787,19 @@ TypeImpl::TypeImpl(const CompilerType &s
SetType(static_type, dynamic_type);
}
-TypeImpl::TypeImpl(const TypePair &pair, const CompilerType &dynamic)
- : m_module_wp(), m_static_type(), m_dynamic_type() {
- SetType(pair, dynamic);
-}
-
void TypeImpl::SetType(const lldb::TypeSP &type_sp) {
- m_static_type.SetType(type_sp);
- if (type_sp)
+ if (type_sp) {
+ m_static_type = type_sp->GetForwardCompilerType();
m_module_wp = type_sp->GetModule();
- else
+ } else {
+ m_static_type.Clear();
m_module_wp = lldb::ModuleWP();
+ }
}
void TypeImpl::SetType(const CompilerType &compiler_type) {
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType(compiler_type);
+ m_static_type = compiler_type;
}
void TypeImpl::SetType(const lldb::TypeSP &type_sp,
@@ -823,13 +811,7 @@ void TypeImpl::SetType(const lldb::TypeS
void TypeImpl::SetType(const CompilerType &compiler_type,
const CompilerType &dynamic) {
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType(compiler_type);
- m_dynamic_type = dynamic;
-}
-
-void TypeImpl::SetType(const TypePair &pair, const CompilerType &dynamic) {
- m_module_wp.reset();
- m_static_type = pair;
+ m_static_type = compiler_type;
m_dynamic_type = dynamic;
}
@@ -900,7 +882,7 @@ ConstString TypeImpl::GetName() const {
if (CheckModule(module_sp)) {
if (m_dynamic_type)
return m_dynamic_type.GetTypeName();
- return m_static_type.GetName();
+ return m_static_type.GetTypeName();
}
return ConstString();
}
@@ -943,10 +925,10 @@ TypeImpl TypeImpl::GetReferenceType() co
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetReferenceType(),
+ return TypeImpl(m_static_type.GetLValueReferenceType(),
m_dynamic_type.GetLValueReferenceType());
}
- return TypeImpl(m_static_type.GetReferenceType());
+ return TypeImpl(m_static_type.GetLValueReferenceType());
}
return TypeImpl();
}
@@ -967,10 +949,10 @@ TypeImpl TypeImpl::GetDereferencedType()
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetDereferencedType(),
+ return TypeImpl(m_static_type.GetNonReferenceType(),
m_dynamic_type.GetNonReferenceType());
}
- return TypeImpl(m_static_type.GetDereferencedType());
+ return TypeImpl(m_static_type.GetNonReferenceType());
}
return TypeImpl();
}
@@ -979,10 +961,10 @@ TypeImpl TypeImpl::GetUnqualifiedType()
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetUnqualifiedType(),
+ return TypeImpl(m_static_type.GetFullyUnqualifiedType(),
m_dynamic_type.GetFullyUnqualifiedType());
}
- return TypeImpl(m_static_type.GetUnqualifiedType());
+ return TypeImpl(m_static_type.GetFullyUnqualifiedType());
}
return TypeImpl();
}
@@ -1006,7 +988,7 @@ CompilerType TypeImpl::GetCompilerType(b
if (m_dynamic_type.IsValid())
return m_dynamic_type;
}
- return m_static_type.GetCompilerType();
+ return m_static_type;
}
return CompilerType();
}
@@ -1018,7 +1000,7 @@ TypeSystem *TypeImpl::GetTypeSystem(bool
if (m_dynamic_type.IsValid())
return m_dynamic_type.GetTypeSystem();
}
- return m_static_type.GetCompilerType().GetTypeSystem();
+ return m_static_type.GetTypeSystem();
}
return NULL;
}
@@ -1032,7 +1014,7 @@ bool TypeImpl::GetDescription(lldb_priva
m_dynamic_type.DumpTypeDescription(&strm);
strm.Printf("\nStatic:\n");
}
- m_static_type.GetCompilerType().DumpTypeDescription(&strm);
+ m_static_type.DumpTypeDescription(&strm);
} else {
strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
}
More information about the lldb-commits
mailing list