Add a method for getting the enumeration underlying type.
Differential revision: https://reviews.llvm.org/D93696
GetCanonicalType();
lldb::SBType
+ GetEnumerationIntegerType();
+
+ lldb::SBType
GetArrayElementType ();
lldb::SBType
lldb::SBType GetVectorElementType();
lldb::SBType GetCanonicalType();
+
+ lldb::SBType GetEnumerationIntegerType();
+
// Get the "lldb::BasicType" enumeration for a type. If a type is not a basic
// type eBasicTypeInvalid will be returned
lldb::BasicType GetBasicType();
CompilerType GetFullyUnqualifiedType() const;
+ CompilerType GetEnumerationIntegerType() const;
+
/// Returns -1 if this isn't a function of if the function doesn't
/// have a prototype Returns a value >= 0 if there is a prototype.
int GetFunctionArgumentCount() const;
virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0;
+ virtual CompilerType
+ GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) = 0;
+
// Returns -1 if this isn't a function of if the function doesn't have a
// prototype Returns a value >= 0 if there is a prototype.
virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0;
return LLDB_RECORD_RESULT(SBType());
}
+SBType SBType::GetEnumerationIntegerType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetEnumerationIntegerType);
+
+ if (IsValid()) {
+ return LLDB_RECORD_RESULT(
+ SBType(m_opaque_sp->GetCompilerType(true).GetEnumerationIntegerType()));
+ }
+ return LLDB_RECORD_RESULT(SBType());
+}
+
lldb::BasicType SBType::GetBasicType() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
GetMemberFunctionAtIndex, (uint32_t));
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetEnumerationIntegerType, ());
LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ());
LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType));
LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ());
return CompilerType();
}
+CompilerType
+TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
+ if (type)
+ return GetEnumerationIntegerType(GetType(GetCanonicalQualType(type)));
+ return CompilerType();
+}
+
int TypeSystemClang::GetFunctionArgumentCount(
lldb::opaque_compiler_type_t type) {
if (type) {
CompilerType
GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override;
+ CompilerType
+ GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override;
+
// Returns -1 if this isn't a function of if the function doesn't have a
// prototype Returns a value >= 0 if there is a prototype.
int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override;
return CompilerType();
}
+CompilerType CompilerType::GetEnumerationIntegerType() const {
+ if (IsValid())
+ return m_type_system->GetEnumerationIntegerType(m_type);
+ return CompilerType();
+}
+
int CompilerType::GetFunctionArgumentCount() const {
if (IsValid()) {
return m_type_system->GetFunctionArgumentCount(m_type);
self.assertTrue(enum_type)
self.DebugSBType(enum_type)
self.assertFalse(enum_type.IsScopedEnumerationType())
+
scoped_enum_type = target.FindFirstType('ScopedEnumType')
self.assertTrue(scoped_enum_type)
self.DebugSBType(scoped_enum_type)
self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+ int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
+ self.assertTrue(int_scoped_enum_type)
+ self.DebugSBType(int_scoped_enum_type)
+ self.assertEquals(int_scoped_enum_type.GetName(), 'int')
+
+ enum_uchar = target.FindFirstType('EnumUChar')
+ self.assertTrue(enum_uchar)
+ self.DebugSBType(enum_uchar)
+ int_enum_uchar = enum_uchar.GetEnumerationIntegerType()
+ self.assertTrue(int_enum_uchar)
+ self.DebugSBType(int_enum_uchar)
+ self.assertEquals(int_enum_uchar.GetName(), 'unsigned char')
enum EnumType {};
enum class ScopedEnumType {};
+enum class EnumUChar : unsigned char {};
int main (int argc, char const *argv[])
{
EnumType enum_type;
ScopedEnumType scoped_enum_type;
+ EnumUChar scoped_enum_type_uchar;
return 0; // Break at this line
}