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 @@ -3234,6 +3234,14 @@ const clang::BuiltinType *builtin_type = llvm::dyn_cast(qual_type->getCanonicalTypeInternal()); + if (!builtin_type) { + if (const clang::EnumType *enum_type = llvm::dyn_cast( + qual_type->getCanonicalTypeInternal())) { + builtin_type = llvm::dyn_cast( + enum_type->getDecl()->getIntegerType()); + } + } + if (!builtin_type) return false; @@ -7597,7 +7605,11 @@ assert(!var->hasInit() && "variable already initialized"); QualType qt = var->getType(); - assert(qt->isSpecificBuiltinType(BuiltinType::Bool) && + assert((qt->isSpecificBuiltinType(BuiltinType::Bool) || + cast(qt) + ->getDecl() + ->getIntegerType() + ->isSpecificBuiltinType(BuiltinType::Bool)) && "only boolean supported"); clang::ASTContext &ast = var->getASTContext(); diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -57,6 +57,8 @@ # Test an unscoped enum. self.expect_expr("A::enum_val", result_value="enum_case2") + # Test an unscoped enum with bool as the underlying type. + self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2") # Test a scoped enum. self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2") diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp --- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp +++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp @@ -5,6 +5,11 @@ enum_case2 = 2, }; +enum EnumBool : bool { + enum_bool_case1 = false, + enum_bool_case2 = true, +}; + enum class ScopedEnum { scoped_enum_case1 = 1, scoped_enum_case2 = 2, @@ -51,6 +56,7 @@ const static auto wchar_min = std::numeric_limits::min(); const static Enum enum_val = enum_case2; + const static EnumBool enum_bool_val = enum_bool_case2; const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2; const static ScopedEnum not_enumerator_scoped_enum_val = static_cast(5); const static ScopedEnum not_enumerator_scoped_enum_val_2 =