diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2471,12 +2471,17 @@ /// syntactic sugar and other constructs one typically wants to ignore. /// The \p mask argument allows one to skip certain kinds of simplifications, /// when one wishes to handle a certain kind of type directly. -static QualType Desugar(QualType type, - ArrayRef mask = {}) { +static QualType +RemoveWrappingTypes(QualType type, ArrayRef mask = {}) { while (true) { if (find(mask, type->getTypeClass()) != mask.end()) return type; switch (type->getTypeClass()) { + // This is not fully correct as _Atomic is more than sugar, but it is + // sufficient for the purposes we care about. + case clang::Type::Atomic: + type = cast(type)->getValueType(); + break; case clang::Type::Auto: case clang::Type::Elaborated: case clang::Type::Paren: @@ -2494,7 +2499,7 @@ if (type.isNull()) return nullptr; - clang::QualType qual_type = Desugar(type.getCanonicalType()); + clang::QualType qual_type = RemoveWrappingTypes(type.getCanonicalType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::ObjCInterface: @@ -2518,7 +2523,7 @@ static bool GetCompleteQualType(clang::ASTContext *ast, clang::QualType qual_type, bool allow_completion = true) { - qual_type = Desugar(qual_type); + qual_type = RemoveWrappingTypes(qual_type); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::ConstantArray: @@ -2652,7 +2657,7 @@ // Tests bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) { - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -2673,7 +2678,7 @@ } bool ClangASTContext::IsAnonymousType(lldb::opaque_compiler_type_t type) { - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -2697,7 +2702,7 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type_ptr, uint64_t *size, bool *is_incomplete) { - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -2861,7 +2866,7 @@ bool ClangASTContext::IsFunctionType(lldb::opaque_compiler_type_t type, bool *is_variadic_ptr) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); if (qual_type->isFunctionType()) { if (is_variadic_ptr) { @@ -2899,7 +2904,7 @@ if (!type) return 0; - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -3004,7 +3009,7 @@ bool ClangASTContext::IsFunctionPointerType(lldb::opaque_compiler_type_t type) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); if (qual_type->isFunctionPointerType()) return true; @@ -3031,7 +3036,7 @@ lldb::opaque_compiler_type_t type, CompilerType *function_pointer_type_ptr) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); if (qual_type->isBlockPointerType()) { if (function_pointer_type_ptr) { @@ -3102,7 +3107,7 @@ bool ClangASTContext::IsPointerType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: @@ -3154,7 +3159,7 @@ bool ClangASTContext::IsPointerOrReferenceType( lldb::opaque_compiler_type_t type, CompilerType *pointee_type) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: @@ -3220,7 +3225,7 @@ CompilerType *pointee_type, bool *is_rvalue) { if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -3383,7 +3388,7 @@ bool check_objc) { clang::QualType pointee_qual_type; if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); bool success = false; const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -3640,7 +3645,7 @@ pointee_or_element_clang_type->Clear(); clang::QualType qual_type = - Desugar(GetQualType(type), {clang::Type::Typedef}); + RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef}); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -3827,11 +3832,6 @@ ->getUnderlyingType() .getAsOpaquePtr()) .GetTypeInfo(pointee_or_element_clang_type); - case clang::Type::Atomic: - return CompilerType(this, llvm::cast(qual_type) - ->getValueType() - .getAsOpaquePtr()) - .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -3945,13 +3945,14 @@ return lldb::eTypeClassInvalid; clang::QualType qual_type = - Desugar(GetQualType(type), {clang::Type::Typedef}); + RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef}); switch (qual_type->getTypeClass()) { + case clang::Type::Atomic: case clang::Type::Auto: case clang::Type::Elaborated: case clang::Type::Paren: - llvm_unreachable("Handled in Desugar!"); + llvm_unreachable("Handled in RemoveWrappingTypes!"); case clang::Type::UnaryTransform: break; case clang::Type::FunctionNoProto: @@ -4052,8 +4053,6 @@ break; case clang::Type::DeducedTemplateSpecialization: break; - case clang::Type::Atomic: - break; case clang::Type::Pipe: break; @@ -4202,7 +4201,7 @@ ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) { size_t num_functions = 0; if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); switch (qual_type->getTypeClass()) { case clang::Type::Record: if (GetCompleteQualType(getASTContext(), qual_type)) { @@ -4266,7 +4265,7 @@ CompilerType clang_type; CompilerDecl clang_decl; if (type) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); switch (qual_type->getTypeClass()) { case clang::Type::Record: if (GetCompleteQualType(getASTContext(), qual_type)) { @@ -4658,14 +4657,15 @@ return lldb::eEncodingInvalid; count = 1; - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); switch (qual_type->getTypeClass()) { + case clang::Type::Atomic: case clang::Type::Auto: case clang::Type::Elaborated: case clang::Type::Paren: case clang::Type::Typedef: - llvm_unreachable("Handled in Desugar!"); + llvm_unreachable("Handled in RemoveWrappingTypes!"); case clang::Type::UnaryTransform: break; @@ -4903,7 +4903,6 @@ case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: - case clang::Type::Atomic: case clang::Type::Adjusted: case clang::Type::Pipe: break; @@ -4927,14 +4926,15 @@ if (!type) return lldb::eFormatDefault; - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); switch (qual_type->getTypeClass()) { + case clang::Type::Atomic: case clang::Type::Auto: case clang::Type::Elaborated: case clang::Type::Paren: case clang::Type::Typedef: - llvm_unreachable("Handled in Desugar!"); + llvm_unreachable("Handled in RemoveWrappingTypes!"); case clang::Type::UnaryTransform: break; @@ -5043,11 +5043,6 @@ ->getUnderlyingType() .getAsOpaquePtr()) .GetFormat(); - case clang::Type::Atomic: - return CompilerType(this, llvm::cast(qual_type) - ->getValueType() - .getAsOpaquePtr()) - .GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5114,7 +5109,7 @@ return 0; uint32_t num_children = 0; - clang::QualType qual_type(Desugar(GetQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: @@ -5381,7 +5376,7 @@ return 0; uint32_t count = 0; - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5501,7 +5496,7 @@ if (!type) return CompilerType(); - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5598,7 +5593,7 @@ uint32_t ClangASTContext::GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) { uint32_t count = 0; - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5650,7 +5645,7 @@ uint32_t ClangASTContext::GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) { uint32_t count = 0; - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5670,7 +5665,7 @@ CompilerType ClangASTContext::GetDirectBaseClassAtIndex( lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5768,7 +5763,7 @@ CompilerType ClangASTContext::GetVirtualBaseClassAtIndex( lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -5818,7 +5813,7 @@ if (type.isNull()) return 0; - clang::QualType qual_type = Desugar(type.getCanonicalType()); + clang::QualType qual_type = RemoveWrappingTypes(type.getCanonicalType()); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Builtin: @@ -5972,7 +5967,8 @@ return exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; }; - clang::QualType parent_qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType parent_qual_type( + RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass parent_type_class = parent_qual_type->getTypeClass(); child_bitfield_bit_size = 0; @@ -6496,7 +6492,7 @@ lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes, std::vector &child_indexes) { if (type && name && name[0]) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -6737,7 +6733,7 @@ const char *name, bool omit_empty_base_classes) { if (type && name && name[0]) { - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); @@ -6936,7 +6932,7 @@ if (!type) return 0; - clang::QualType qual_type = Desugar(GetCanonicalQualType(type)); + clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: @@ -6966,7 +6962,7 @@ if (!type) return nullptr; - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { case clang::Type::Record: { @@ -7939,7 +7935,7 @@ if (!type) return false; - clang::QualType qual_type(Desugar(GetCanonicalQualType(type))); + clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type))); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -8871,7 +8867,7 @@ Stream *s) { if (type) { clang::QualType qual_type = - Desugar(GetQualType(type), {clang::Type::Typedef}); + RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef}); llvm::SmallVector buf; llvm::raw_svector_ostream llvm_ostrm(buf); diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s --- a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s +++ b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-atomic.s @@ -4,13 +4,13 @@ # RUN: %lldb %t -o "target variable integer structure" -o exit | FileCheck %s # CHECK: (_Atomic(int)) integer = 14159 -# CHECK: (_Atomic(struct_type)) structure = {} +# CHECK: (_Atomic(struct_type)) structure = (member = 71828) .data integer: .long 14159 structure: - .byte 0 + .long 71828 .section .debug_abbrev,"",@progbits .byte 1 # Abbreviation Code @@ -53,13 +53,24 @@ .byte 0 # EOM(2) .byte 5 # Abbreviation Code .byte 19 # DW_TAG_structure_type - .byte 0 # DW_CHILDREN_no + .byte 1 # DW_CHILDREN_yes .byte 3 # DW_AT_name .byte 8 # DW_FORM_string .byte 11 # DW_AT_byte_size .byte 11 # DW_FORM_data1 .byte 0 # EOM(1) .byte 0 # EOM(2) + .byte 6 # Abbreviation Code + .byte 13 # DW_TAG_member + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 56 # DW_AT_data_member_location + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) .byte 0 # EOM(3) .section .debug_info,"",@progbits @@ -99,6 +110,11 @@ .Lstruct: .byte 5 # Abbrev [5] DW_TAG_structure_type .asciz "struct_type" # DW_AT_name - .byte 0 # DW_AT_byte_size + .byte 4 # DW_AT_byte_size + .byte 6 # Abbrev [6] DW_TAG_member + .asciz "member" # DW_AT_name + .long .Lint # DW_AT_type + .byte 0 # DW_AT_data_member_location + .byte 0 # End Of Children Mark .byte 0 # End Of Children Mark .Ldebug_info_end0: