diff --git a/lldb/bindings/interface/SBType.i b/lldb/bindings/interface/SBType.i --- a/lldb/bindings/interface/SBType.i +++ b/lldb/bindings/interface/SBType.i @@ -220,6 +220,9 @@ bool IsAnonymousType (); + bool + IsScopedEnumerationType (); + lldb::SBType GetPointerType(); diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -131,6 +131,8 @@ bool IsAnonymousType(); + bool IsScopedEnumerationType(); + lldb::SBType GetPointerType(); lldb::SBType GetPointeeType(); diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -82,6 +82,8 @@ bool IsAnonymousType() const; + bool IsScopedEnumerationType() const; + bool IsBeingDefined() const; bool IsCharType() const; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -176,6 +176,8 @@ return false; } + virtual bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) = 0; + virtual bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, CompilerType *target_type, // Can pass NULL bool check_cplusplus, bool check_objc) = 0; diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -271,6 +271,14 @@ return m_opaque_sp->GetCompilerType(true).IsAnonymousType(); } +bool SBType::IsScopedEnumerationType() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsScopedEnumerationType); + + if (!IsValid()) + return false; + return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType(); +} + lldb::SBType SBType::GetFunctionReturnType() { LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -612,6 +612,8 @@ bool IsEnumerationType(lldb::opaque_compiler_type_t type, bool &is_signed) override; + bool IsScopedEnumerationType(lldb::opaque_compiler_type_t type) override; + static bool IsObjCClassType(const CompilerType &type); static bool IsObjCClassTypeAndHasIVars(const CompilerType &type, diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -3141,6 +3141,20 @@ return false; } +bool TypeSystemClang::IsScopedEnumerationType( + lldb::opaque_compiler_type_t type) { + if (type) { + const clang::EnumType *enum_type = llvm::dyn_cast( + GetCanonicalQualType(type)->getCanonicalTypeInternal()); + + if (enum_type) { + return enum_type->isScopedEnumeralType(); + } + } + + return false; +} + bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) { if (type) { diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -40,6 +40,12 @@ return false; } +bool CompilerType::IsScopedEnumerationType() const { + if (IsValid()) + return m_type_system->IsScopedEnumerationType(m_type); + return false; +} + bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size, bool *is_incomplete) const { if (IsValid()) diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -144,3 +144,13 @@ myint_type = target.FindFirstType('myint') self.DebugSBType(myint_type) self.assertTrue(myint_arr_element_type == myint_type) + + # Test enum methods. + enum_type = target.FindFirstType('EnumType') + 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()) diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -29,6 +29,8 @@ {} }; +enum EnumType {}; +enum class ScopedEnumType {}; int main (int argc, char const *argv[]) { @@ -59,5 +61,8 @@ typedef int myint; myint myint_arr[] = {1, 2, 3}; + EnumType enum_type; + ScopedEnumType scoped_enum_type; + return 0; // Break at this line }