Add logic to ClangASTType and SBType to discover information about vector types

llvm-svn: 227383
This commit is contained in:
Enrico Granata 2015-01-28 22:18:02 +00:00
parent 563cba6d2b
commit 7684e6e1c2
5 changed files with 69 additions and 1 deletions

View File

@ -152,6 +152,9 @@ public:
bool
IsArrayType ();
bool
IsVectorType ();
bool
IsTypedefType ();
@ -175,6 +178,9 @@ public:
lldb::SBType
GetArrayElementType ();
lldb::SBType
GetVectorElementType ();
lldb::SBType
GetCanonicalType();

View File

@ -96,6 +96,10 @@ public:
uint64_t *size,
bool *is_incomplete) const;
bool
IsVectorType (ClangASTType *element_type,
uint64_t *size) const;
bool
IsArrayOfScalarType () const;

View File

@ -209,6 +209,9 @@ public:
bool
IsArrayType ();
bool
IsVectorType ();
bool
IsTypedefType ();
@ -235,6 +238,9 @@ public:
lldb::SBType
GetArrayElementType ();
lldb::SBType
GetVectorElementType ();
lldb::BasicType
GetBasicType();

View File

@ -163,6 +163,14 @@ SBType::IsArrayType()
return m_opaque_sp->GetClangASTType(true).IsArrayType(nullptr, nullptr, nullptr);
}
bool
SBType::IsVectorType()
{
if (!IsValid())
return false;
return m_opaque_sp->GetClangASTType(true).IsVectorType(nullptr, nullptr);
}
bool
SBType::IsReferenceType()
{
@ -220,7 +228,20 @@ SBType::GetArrayElementType()
return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetClangASTType(true).GetArrayElementType())));
}
bool
SBType
SBType::GetVectorElementType ()
{
SBType type_sb;
if (IsValid())
{
ClangASTType vector_element_type;
if (m_opaque_sp->GetClangASTType(true).IsVectorType(&vector_element_type, nullptr))
type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
}
return type_sb;
}
bool
SBType::IsFunctionType ()
{
if (!IsValid())

View File

@ -289,6 +289,37 @@ ClangASTType::IsArrayType (ClangASTType *element_type_ptr,
return 0;
}
bool
ClangASTType::IsVectorType (ClangASTType *element_type,
uint64_t *size) const
{
if (IsValid())
{
clang::QualType qual_type (GetCanonicalQualType());
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
switch (type_class)
{
case clang::Type::Vector:
{
const clang::VectorType *vector_type = qual_type->getAs<clang::VectorType>();
if (vector_type)
{
if (size)
*size = vector_type->getNumElements();
if (element_type)
*element_type = ClangASTType(m_ast, vector_type->getElementType().getAsOpaquePtr());
}
return true;
}
break;
default:
break;
}
}
return false;
}
bool
ClangASTType::IsRuntimeGeneratedType () const
{