summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/API/SBType.h6
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h3
-rw-r--r--lldb/include/lldb/lldb-enumerations.h8
-rw-r--r--lldb/scripts/Python/interface/SBType.i3
-rw-r--r--lldb/source/API/SBType.cpp73
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp57
6 files changed, 123 insertions, 27 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index cc582c1129f..85dfcf46d70 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -105,6 +105,12 @@ public:
lldb::SBType
GetUnqualifiedType();
+ // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
+ // type eBasicTypeInvalid will be returned
+ lldb::BasicType
+ GetBasicType();
+
+ // The call below confusing and should really be renamed to "CreateBasicType"
lldb::SBType
GetBasicType(lldb::BasicType type);
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index b99cf5576ff..9f2c038563d 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -274,6 +274,9 @@ public:
lldb::clang_type_t
GetTypeForDecl (clang::ObjCInterfaceDecl *objc_decl);
+ static lldb::BasicType
+ GetLLDBBasicTypeEnumeration (lldb::clang_type_t clang_type);
+
//------------------------------------------------------------------
// CVR modifiers
//------------------------------------------------------------------
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index a3580d4e556..cadc9937fb8 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -537,7 +537,10 @@ namespace lldb {
eBasicTypeVoid = 1,
eBasicTypeChar,
eBasicTypeSignedChar,
+ eBasicTypeUnsignedChar,
eBasicTypeWChar,
+ eBasicTypeSignedWChar,
+ eBasicTypeUnsignedWChar,
eBasicTypeChar16,
eBasicTypeChar32,
eBasicTypeShort,
@@ -551,6 +554,7 @@ namespace lldb {
eBasicTypeInt128,
eBasicTypeUnsignedInt128,
eBasicTypeBool,
+ eBasicTypeHalf,
eBasicTypeFloat,
eBasicTypeDouble,
eBasicTypeLongDouble,
@@ -559,7 +563,9 @@ namespace lldb {
eBasicTypeLongDoubleComplex,
eBasicTypeObjCID,
eBasicTypeObjCClass,
- eBasicTypeObjCSel
+ eBasicTypeObjCSel,
+ eBasicTypeNullPtr,
+ eBasicTypeOther
} BasicType;
typedef enum TypeClass
diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i
index e2904f85a23..76fdfc923bd 100644
--- a/lldb/scripts/Python/interface/SBType.i
+++ b/lldb/scripts/Python/interface/SBType.i
@@ -177,6 +177,9 @@ public:
lldb::SBType
GetUnqualifiedType();
+ lldb::BasicType
+ GetBasicType();
+
lldb::SBType
GetBasicType (lldb::BasicType type);
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index a65f29b779e..3e6d8f59c5d 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -229,24 +229,51 @@ SBType::GetUnqualifiedType()
return SBType(ClangASTType(m_opaque_sp->GetASTContext(),qt.getUnqualifiedType().getAsOpaquePtr()));
}
+lldb::BasicType
+SBType::GetBasicType()
+{
+ if (IsValid())
+ return ClangASTContext::GetLLDBBasicTypeEnumeration (m_opaque_sp->GetOpaqueQualType());
+ return eBasicTypeInvalid;
+}
SBType
SBType::GetBasicType(lldb::BasicType type)
{
-
if (!IsValid())
return SBType();
- clang::CanQualType base_type_qual;
+ clang::QualType base_type_qual;
switch (type)
{
+ case eBasicTypeVoid:
+ base_type_qual = m_opaque_sp->GetASTContext()->VoidTy;
+ break;
case eBasicTypeChar:
base_type_qual = m_opaque_sp->GetASTContext()->CharTy;
break;
case eBasicTypeSignedChar:
base_type_qual = m_opaque_sp->GetASTContext()->SignedCharTy;
break;
+ case eBasicTypeUnsignedChar:
+ base_type_qual = m_opaque_sp->GetASTContext()->UnsignedCharTy;
+ break;
+ case eBasicTypeWChar:
+ base_type_qual = m_opaque_sp->GetASTContext()->getWCharType();
+ break;
+ case eBasicTypeSignedWChar:
+ base_type_qual = m_opaque_sp->GetASTContext()->getSignedWCharType();
+ break;
+ case eBasicTypeUnsignedWChar:
+ base_type_qual = m_opaque_sp->GetASTContext()->getUnsignedWCharType();
+ break;
+ case eBasicTypeChar16:
+ base_type_qual = m_opaque_sp->GetASTContext()->Char16Ty;
+ break;
+ case eBasicTypeChar32:
+ base_type_qual = m_opaque_sp->GetASTContext()->Char32Ty;
+ break;
case eBasicTypeShort:
base_type_qual = m_opaque_sp->GetASTContext()->ShortTy;
break;
@@ -265,30 +292,6 @@ SBType::GetBasicType(lldb::BasicType type)
case eBasicTypeUnsignedLong:
base_type_qual = m_opaque_sp->GetASTContext()->UnsignedLongTy;
break;
- case eBasicTypeBool:
- base_type_qual = m_opaque_sp->GetASTContext()->BoolTy;
- break;
- case eBasicTypeFloat:
- base_type_qual = m_opaque_sp->GetASTContext()->FloatTy;
- break;
- case eBasicTypeDouble:
- base_type_qual = m_opaque_sp->GetASTContext()->DoubleTy;
- break;
- case eBasicTypeObjCID:
- base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinIdTy;
- break;
- case eBasicTypeVoid:
- base_type_qual = m_opaque_sp->GetASTContext()->VoidTy;
- break;
- case eBasicTypeWChar:
- base_type_qual = m_opaque_sp->GetASTContext()->WCharTy;
- break;
- case eBasicTypeChar16:
- base_type_qual = m_opaque_sp->GetASTContext()->Char16Ty;
- break;
- case eBasicTypeChar32:
- base_type_qual = m_opaque_sp->GetASTContext()->Char32Ty;
- break;
case eBasicTypeLongLong:
base_type_qual = m_opaque_sp->GetASTContext()->LongLongTy;
break;
@@ -301,6 +304,18 @@ SBType::GetBasicType(lldb::BasicType type)
case eBasicTypeUnsignedInt128:
base_type_qual = m_opaque_sp->GetASTContext()->UnsignedInt128Ty;
break;
+ case eBasicTypeBool:
+ base_type_qual = m_opaque_sp->GetASTContext()->BoolTy;
+ break;
+ case eBasicTypeHalf:
+ base_type_qual = m_opaque_sp->GetASTContext()->HalfTy;
+ break;
+ case eBasicTypeFloat:
+ base_type_qual = m_opaque_sp->GetASTContext()->FloatTy;
+ break;
+ case eBasicTypeDouble:
+ base_type_qual = m_opaque_sp->GetASTContext()->DoubleTy;
+ break;
case eBasicTypeLongDouble:
base_type_qual = m_opaque_sp->GetASTContext()->LongDoubleTy;
break;
@@ -313,12 +328,18 @@ SBType::GetBasicType(lldb::BasicType type)
case eBasicTypeLongDoubleComplex:
base_type_qual = m_opaque_sp->GetASTContext()->LongDoubleComplexTy;
break;
+ case eBasicTypeObjCID:
+ base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinIdTy;
+ break;
case eBasicTypeObjCClass:
base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinClassTy;
break;
case eBasicTypeObjCSel:
base_type_qual = m_opaque_sp->GetASTContext()->ObjCBuiltinSelTy;
break;
+ case eBasicTypeNullPtr:
+ base_type_qual = m_opaque_sp->GetASTContext()->NullPtrTy;
+ break;
default:
return SBType();
}
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index efd8de72d5d..57e2ac1e09f 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -3644,6 +3644,63 @@ ClangASTContext::GetFieldAtIndex (clang::ASTContext *ast,
return NULL;
}
+lldb::BasicType
+ClangASTContext::GetLLDBBasicTypeEnumeration (clang_type_t clang_type)
+{
+ if (clang_type)
+ {
+ QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+ const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+ switch (type_class)
+ {
+ case clang::Type::Builtin:
+ switch (cast<clang::BuiltinType>(qual_type)->getKind())
+
+ case clang::BuiltinType::Void: return eBasicTypeVoid;
+ case clang::BuiltinType::Bool: return eBasicTypeBool;
+ case clang::BuiltinType::Char_S: return eBasicTypeSignedChar;
+ case clang::BuiltinType::Char_U: return eBasicTypeUnsignedChar;
+ case clang::BuiltinType::Char16: return eBasicTypeChar16;
+ case clang::BuiltinType::Char32: return eBasicTypeChar32;
+ case clang::BuiltinType::UChar: return eBasicTypeUnsignedChar;
+ case clang::BuiltinType::SChar: return eBasicTypeSignedChar;
+ case clang::BuiltinType::WChar_S: return eBasicTypeSignedWChar;
+ case clang::BuiltinType::WChar_U: return eBasicTypeUnsignedWChar;
+ case clang::BuiltinType::Short: return eBasicTypeShort;
+ case clang::BuiltinType::UShort: return eBasicTypeUnsignedShort;
+ case clang::BuiltinType::Int: return eBasicTypeInt;
+ case clang::BuiltinType::UInt: return eBasicTypeUnsignedInt;
+ case clang::BuiltinType::Long: return eBasicTypeLong;
+ case clang::BuiltinType::ULong: return eBasicTypeUnsignedLong;
+ case clang::BuiltinType::LongLong: return eBasicTypeLongLong;
+ case clang::BuiltinType::ULongLong: return eBasicTypeUnsignedLongLong;
+ case clang::BuiltinType::Int128: return eBasicTypeInt128;
+ case clang::BuiltinType::UInt128: return eBasicTypeUnsignedInt128;
+
+ case clang::BuiltinType::Half: return eBasicTypeHalf;
+ case clang::BuiltinType::Float: return eBasicTypeFloat;
+ case clang::BuiltinType::Double: return eBasicTypeDouble;
+ case clang::BuiltinType::LongDouble:return eBasicTypeLongDouble;
+
+ case clang::BuiltinType::NullPtr: return eBasicTypeNullPtr;
+ case clang::BuiltinType::ObjCId: return eBasicTypeObjCID;
+ case clang::BuiltinType::ObjCClass: return eBasicTypeObjCClass;
+ case clang::BuiltinType::ObjCSel: return eBasicTypeObjCSel;
+ case clang::BuiltinType::Dependent:
+ case clang::BuiltinType::Overload:
+ case clang::BuiltinType::BoundMember:
+ case clang::BuiltinType::PseudoObject:
+ case clang::BuiltinType::UnknownAny:
+ case clang::BuiltinType::BuiltinFn:
+ case clang::BuiltinType::ARCUnbridgedCast:
+ return eBasicTypeOther;
+ }
+ }
+
+ return eBasicTypeInvalid;
+}
+
+
// If a pointer to a pointee type (the clang_type arg) says that it has no
// children, then we either need to trust it, or override it and return a
OpenPOWER on IntegriCloud