Delete type_sp member from TypePair

Summary:
As discussed in the review of D59217, this member is unnecessary since
always the first thing we do is convert it to a CompilerType.

This opens up possibilities for further cleanups (e.g. the whole
TypePair class now loses purpose, since we can just pass around
CompilerType everywhere), but I did not want to do that yet, because I
am not sure if this will not introduce breakages in some of the
platforms/configurations that I am not testing on.

Reviewers: clayborg, zturner, jingham

Subscribers: jdoerfert, lldb-commits

Differential Revision: https://reviews.llvm.org/D59297

llvm-svn: 356262
This commit is contained in:
Pavel Labath 2019-03-15 14:02:35 +00:00
parent 373bee85c2
commit a933d6c7c0
4 changed files with 18 additions and 79 deletions

View File

@ -139,12 +139,6 @@ public:
return nullptr;
}
lldb::TypeSP GetTypeSP() {
if (m_type.m_type_pair.IsValid())
return m_type.m_type_pair.GetTypeSP();
return lldb::TypeSP();
}
CompilerType GetCompilerType() {
if (m_type.m_type_pair.IsValid())
return m_type.m_type_pair.GetCompilerType();

View File

@ -239,19 +239,16 @@ protected:
// 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(), type_sp() {}
TypePair() : compiler_type() {}
TypePair(CompilerType type) : compiler_type(type), type_sp() {}
TypePair(CompilerType type) : compiler_type(type) {}
TypePair(lldb::TypeSP type) : compiler_type(), type_sp(type) {
compiler_type = type_sp->GetForwardCompilerType();
}
TypePair(lldb::TypeSP type) : compiler_type(type->GetForwardCompilerType()) {}
bool IsValid() const {
return compiler_type.IsValid() || (type_sp.get() != nullptr);
}
bool IsValid() const { return compiler_type.IsValid(); }
explicit operator bool() const { return IsValid(); }
@ -261,101 +258,58 @@ public:
bool operator!=(const TypePair &rhs) const { return !(*this == rhs); }
void Clear() {
compiler_type.Clear();
type_sp.reset();
}
void Clear() { compiler_type.Clear(); }
ConstString GetName() const {
if (type_sp)
return type_sp->GetName();
if (compiler_type)
return compiler_type.GetTypeName();
return ConstString();
}
ConstString GetDisplayTypeName() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetDisplayTypeName();
if (compiler_type)
return compiler_type.GetDisplayTypeName();
return ConstString();
}
void SetType(CompilerType type) {
type_sp.reset();
compiler_type = type;
}
void SetType(lldb::TypeSP type) {
type_sp = type;
if (type_sp)
compiler_type = type_sp->GetForwardCompilerType();
else
compiler_type.Clear();
compiler_type = type->GetForwardCompilerType();
}
lldb::TypeSP GetTypeSP() const { return type_sp; }
CompilerType GetCompilerType() const { return compiler_type; }
CompilerType GetPointerType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetPointerType();
return compiler_type.GetPointerType();
}
CompilerType GetPointerType() const { return compiler_type.GetPointerType(); }
CompilerType GetPointeeType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetPointeeType();
return compiler_type.GetPointeeType();
}
CompilerType GetPointeeType() const { return compiler_type.GetPointeeType(); }
CompilerType GetReferenceType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetLValueReferenceType();
else
return compiler_type.GetLValueReferenceType();
return compiler_type.GetLValueReferenceType();
}
CompilerType GetTypedefedType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetTypedefedType();
else
return compiler_type.GetTypedefedType();
return compiler_type.GetTypedefedType();
}
CompilerType GetDereferencedType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetNonReferenceType();
else
return compiler_type.GetNonReferenceType();
return compiler_type.GetNonReferenceType();
}
CompilerType GetUnqualifiedType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType();
else
return compiler_type.GetFullyUnqualifiedType();
return compiler_type.GetFullyUnqualifiedType();
}
CompilerType GetCanonicalType() const {
if (type_sp)
return type_sp->GetForwardCompilerType().GetCanonicalType();
return compiler_type.GetCanonicalType();
}
TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); }
lldb::ModuleSP GetModule() const {
if (type_sp)
return type_sp->GetModule();
return lldb::ModuleSP();
}
protected:
CompilerType compiler_type;
lldb::TypeSP type_sp;
};
// the two classes here are used by the public API as a backend to the SBType
@ -537,8 +491,6 @@ public:
ConstString GetName() const;
lldb::TypeSP GetTypeSP() const { return m_type_pair.GetTypeSP(); }
CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); }
void SetName(ConstString type_name);
@ -553,11 +505,9 @@ public:
bool HasName() const;
bool HasTypeSP() const;
bool HasCompilerType() const;
bool HasType() const { return HasTypeSP() || HasCompilerType(); }
bool HasType() const { return HasCompilerType(); }
void Clear();

View File

@ -235,16 +235,15 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
if (!class_type_or_name)
return false;
TypeSP type_sp = class_type_or_name.GetTypeSP();
CompilerType type = class_type_or_name.GetCompilerType();
// There can only be one type with a given name, so we've just found
// duplicate definitions, and this one will do as well as any other. We
// don't consider something to have a dynamic type if it is the same as
// the static type. So compare against the value we were handed.
if (!type_sp)
if (!type)
return true;
if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(),
type_sp->GetForwardCompilerType())) {
if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(), type)) {
// The dynamic type we found was the same type, so we don't have a
// dynamic type here...
return false;

View File

@ -765,10 +765,6 @@ void TypeAndOrName::Clear() {
bool TypeAndOrName::HasName() const { return (bool)m_type_name; }
bool TypeAndOrName::HasTypeSP() const {
return m_type_pair.GetTypeSP().get() != nullptr;
}
bool TypeAndOrName::HasCompilerType() const {
return m_type_pair.GetCompilerType().IsValid();
}
@ -832,7 +828,7 @@ void TypeImpl::SetType(const CompilerType &compiler_type,
}
void TypeImpl::SetType(const TypePair &pair, const CompilerType &dynamic) {
m_module_wp = pair.GetModule();
m_module_wp.reset();
m_static_type = pair;
m_dynamic_type = dynamic;
}