Skip to content

Commit

Permalink
Remove the TypePair class
Browse files Browse the repository at this point in the history
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

llvm-svn: 356993
  • Loading branch information
labath committed Mar 26, 2019
1 parent f2ffb47 commit 9876add
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 148 deletions.
13 changes: 6 additions & 7 deletions lldb/include/lldb/DataFormatters/FormatClasses.h
Expand Up @@ -122,14 +122,14 @@ class TypeNameSpecifierImpl {
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;
}
}

Expand All @@ -140,20 +140,19 @@ class TypeNameSpecifierImpl {
}

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();
}

bool IsRegex() { return m_is_regex; }

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;

Expand Down
90 changes: 4 additions & 86 deletions lldb/include/lldb/Symbol/Type.h
Expand Up @@ -237,81 +237,6 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
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

Expand All @@ -331,8 +256,6 @@ class TypeImpl {

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);
Expand All @@ -341,8 +264,6 @@ class TypeImpl {

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;
Expand Down Expand Up @@ -384,7 +305,7 @@ class TypeImpl {
bool CheckModule(lldb::ModuleSP &module_sp) const;

lldb::ModuleWP m_module_wp;
TypePair m_static_type;
CompilerType m_static_type;
CompilerType m_dynamic_type;
};

Expand Down Expand Up @@ -476,22 +397,19 @@ class TypeMemberImpl {

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);

Expand All @@ -514,7 +432,7 @@ class TypeAndOrName {
explicit operator bool() { return !IsEmpty(); }

private:
TypePair m_type_pair;
CompilerType m_compiler_type;
ConstString m_type_name;
};

Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/lldb-forward.h
Expand Up @@ -273,7 +273,6 @@ class TypeEnumMemberImpl;
class TypeEnumMemberListImpl;
class TypeFormatImpl;
class TypeNameSpecifierImpl;
class TypePair;
class TypeValidatorImpl;
class UUID;
class UnixSignals;
Expand Down

0 comments on commit 9876add

Please sign in to comment.