diff options
5 files changed, 247 insertions, 9 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index b2e98c26a8d..a69343b1fc7 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -170,6 +170,9 @@ GetCompleteQualType (clang::ASTContext *ast, clang::QualType qual_type, bool all case clang::Type::Elaborated: return GetCompleteQualType (ast, cast<ElaboratedType>(qual_type)->getNamedType(), allow_completion); + case clang::Type::Paren: + return GetCompleteQualType (ast, cast<ParenType>(qual_type)->desugar(), allow_completion); + default: break; } @@ -1454,6 +1457,9 @@ ClangASTContext::SetHasExternalStorage (clang_type_t clang_type, bool has_extern case clang::Type::Elaborated: return ClangASTContext::SetHasExternalStorage (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), has_extern); + case clang::Type::Paren: + return ClangASTContext::SetHasExternalStorage (cast<ParenType>(qual_type)->desugar().getAsOpaquePtr(), has_extern); + default: break; } @@ -2865,6 +2871,9 @@ ClangASTContext::GetNumTemplateArguments (clang::ASTContext *ast, clang_type_t c case clang::Type::Elaborated: return ClangASTContext::GetNumTemplateArguments (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + case clang::Type::Paren: + return ClangASTContext::GetNumTemplateArguments(ast, cast<ParenType>(qual_type)->desugar().getAsOpaquePtr()); + default: break; } @@ -2941,6 +2950,9 @@ ClangASTContext::GetTemplateArgument (clang::ASTContext *ast, clang_type_t clang case clang::Type::Elaborated: return ClangASTContext::GetTemplateArgument (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), arg_idx, kind); + + case clang::Type::Paren: + return ClangASTContext::GetTemplateArgument(ast, cast<ParenType>(qual_type)->desugar().getAsOpaquePtr(), arg_idx, kind); default: break; @@ -3065,6 +3077,12 @@ ClangASTContext::GetTypeInfo return ClangASTContext::GetTypeInfo (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), ast, pointee_or_element_clang_type); + + case clang::Type::Paren: + return ClangASTContext::GetTypeInfo(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + ast, + pointee_or_element_clang_type); + case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue; case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue; case clang::Type::InjectedClassName: return 0; @@ -3155,7 +3173,8 @@ ClangASTContext::IsAggregateType (clang_type_t clang_type) return ClangASTContext::IsAggregateType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::Typedef: return ClangASTContext::IsAggregateType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); - + case clang::Type::Paren: + return ClangASTContext::IsAggregateType (cast<ParenType>(qual_type)->desugar().getAsOpaquePtr()); default: break; } @@ -3333,6 +3352,12 @@ ClangASTContext::GetNumChildren (clang::ASTContext *ast, clang_type_t clang_type omit_empty_base_classes); break; + case clang::Type::Paren: + num_children = ClangASTContext::GetNumChildren(ast, + llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + omit_empty_base_classes); + + break; default: break; } @@ -3383,6 +3408,9 @@ ClangASTContext::GetNumDirectBaseClasses (clang::ASTContext *ast, clang_type_t c count = ClangASTContext::GetNumDirectBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); break; + case clang::Type::Paren: + return ClangASTContext::GetNumDirectBaseClasses(ast, cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); + default: break; } @@ -3418,6 +3446,10 @@ ClangASTContext::GetNumVirtualBaseClasses (clang::ASTContext *ast, count = ClangASTContext::GetNumVirtualBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); break; + case clang::Type::Paren: + count = ClangASTContext::GetNumVirtualBaseClasses(ast, cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); + break; + default: break; } @@ -3462,6 +3494,10 @@ ClangASTContext::GetNumFields (clang::ASTContext *ast, clang_type_t clang_type) count = ClangASTContext::GetNumFields (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); break; + case clang::Type::Paren: + count = ClangASTContext::GetNumFields(ast, cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); + break; + case clang::Type::ObjCObject: case clang::Type::ObjCInterface: if (GetCompleteQualType (ast, qual_type)) @@ -3562,6 +3598,12 @@ ClangASTContext::GetDirectBaseClassAtIndex (clang::ASTContext *ast, idx, bit_offset_ptr); + case clang::Type::Paren: + return ClangASTContext::GetDirectBaseClassAtIndex (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + idx, + bit_offset_ptr); + default: break; } @@ -3621,6 +3663,12 @@ ClangASTContext::GetVirtualBaseClassAtIndex (clang::ASTContext *ast, idx, bit_offset_ptr); + case clang::Type::Paren: + return ClangASTContext::GetVirtualBaseClassAtIndex (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + idx, + bit_offset_ptr); + default: break; } @@ -3771,6 +3819,15 @@ ClangASTContext::GetFieldAtIndex (clang::ASTContext *ast, bitfield_bit_size_ptr, is_bitfield_ptr); + case clang::Type::Paren: + return ClangASTContext::GetFieldAtIndex (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + idx, + name, + bit_offset_ptr, + bitfield_bit_size_ptr, + is_bitfield_ptr); + default: break; } @@ -3950,7 +4007,7 @@ ClangASTContext::GetNumPointeeChildren (clang_type_t clang_type) case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children... case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children... case clang::Type::UnresolvedUsing: return 0; - case clang::Type::Paren: return 0; + case clang::Type::Paren: return ClangASTContext::GetNumPointeeChildren (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); case clang::Type::Typedef: return ClangASTContext::GetNumPointeeChildren (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTContext::GetNumPointeeChildren (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::TypeOfExpr: return 0; @@ -4494,7 +4551,25 @@ ClangASTContext::GetChildClangTypeAtIndex child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, - child_is_deref_of_parent); + child_is_deref_of_parent); + + case clang::Type::Paren: + return GetChildClangTypeAtIndex (exe_ctx, + ast, + parent_name, + llvm::cast<clang::ParenType>(parent_qual_type)->desugar().getAsOpaquePtr(), + idx, + transparent_pointers, + omit_empty_base_classes, + ignore_array_bounds, + child_name, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class, + child_is_deref_of_parent); + default: break; @@ -4945,6 +5020,13 @@ ClangASTContext::GetIndexOfChildMemberWithName name, omit_empty_base_classes, child_indexes); + + case clang::Type::Paren: + return GetIndexOfChildMemberWithName (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + name, + omit_empty_base_classes, + child_indexes); default: break; @@ -5159,6 +5241,12 @@ ClangASTContext::GetIndexOfChildWithName name, omit_empty_base_classes); + case clang::Type::Paren: + return GetIndexOfChildWithName (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + name, + omit_empty_base_classes); + case clang::Type::Typedef: return GetIndexOfChildWithName (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), @@ -5235,6 +5323,7 @@ ClangASTContext::GetDeclContextForType (clang_type_t clang_type) case clang::Type::Enum: return cast<EnumType>(qual_type)->getDecl(); case clang::Type::Typedef: return ClangASTContext::GetDeclContextForType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTContext::GetDeclContextForType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + case clang::Type::Paren: return ClangASTContext::GetDeclContextForType (cast<ParenType>(qual_type)->desugar().getAsOpaquePtr()); case clang::Type::TypeOfExpr: break; case clang::Type::TypeOf: break; case clang::Type::Decltype: break; @@ -5246,7 +5335,6 @@ ClangASTContext::GetDeclContextForType (clang_type_t clang_type) case clang::Type::SubstTemplateTypeParmPack:break; case clang::Type::PackExpansion: break; case clang::Type::UnresolvedUsing: break; - case clang::Type::Paren: break; case clang::Type::Attributed: break; case clang::Type::Auto: break; case clang::Type::InjectedClassName: break; @@ -5827,7 +5915,13 @@ ClangASTContext::IsPossibleDynamicType (clang::ASTContext *ast, dynamic_pointee_type, check_cplusplus, check_objc); - + + case clang::Type::Paren: + return ClangASTContext::IsPossibleDynamicType (ast, + cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + dynamic_pointee_type, + check_cplusplus, + check_objc); default: break; } @@ -5983,6 +6077,9 @@ ClangASTContext::IsReferenceType (clang_type_t clang_type, clang_type_t *target_ return ClangASTContext::IsReferenceType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTContext::IsReferenceType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + case clang::Type::Paren: + return ClangASTContext::IsReferenceType (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); + default: break; } @@ -6038,6 +6135,8 @@ ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t return ClangASTContext::IsPointerOrReferenceType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTContext::IsPointerOrReferenceType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + case clang::Type::Paren: + return ClangASTContext::IsPointerOrReferenceType (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); default: break; } @@ -6107,6 +6206,8 @@ ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t *target_ty return ClangASTContext::IsPointerType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), target_type); case clang::Type::Elaborated: return ClangASTContext::IsPointerType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), target_type); + case clang::Type::Paren: + return ClangASTContext::IsPointerType (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), target_type); default: break; } @@ -6354,6 +6455,8 @@ ClangASTContext::IsFunctionPointerType (clang_type_t clang_type) return ClangASTContext::IsFunctionPointerType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTContext::IsFunctionPointerType (cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + case clang::Type::Paren: + return ClangASTContext::IsFunctionPointerType (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); case clang::Type::LValueReference: case clang::Type::RValueReference: @@ -6390,6 +6493,9 @@ ClangASTContext::GetArraySize (clang_type_t clang_type) case clang::Type::Elaborated: return ClangASTContext::GetArraySize(cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); + + case clang::Type::Paren: + return ClangASTContext::GetArraySize(cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); default: break; @@ -6455,6 +6561,11 @@ ClangASTContext::GetAsArrayType (clang_type_t clang_type, clang_type_t*member_ty member_type, size, is_incomplete); + case clang::Type::Paren: + return ClangASTContext::GetAsArrayType (cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + member_type, + size, + is_incomplete); } return 0; } diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 16e0d488e86..fa0e345312c 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -251,7 +251,8 @@ ClangASTType::GetTypeClass (clang::ASTContext *ast_context, lldb::clang_type_t c case clang::Type::Enum: return lldb::eTypeClassEnumeration; case clang::Type::Typedef: return lldb::eTypeClassTypedef; case clang::Type::UnresolvedUsing: break; - case clang::Type::Paren: break; + case clang::Type::Paren: + return ClangASTType::GetTypeClass (ast_context, llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTType::GetTypeClass (ast_context, llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); @@ -464,10 +465,12 @@ ClangASTType::GetEncoding (clang_type_t clang_type, uint64_t &count) case clang::Type::Elaborated: return ClangASTType::GetEncoding (llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(), count); + case clang::Type::Paren: + return ClangASTType::GetEncoding (llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), count); + case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: - case clang::Type::Paren: case clang::Type::Attributed: case clang::Type::TemplateTypeParm: case clang::Type::SubstTemplateTypeParm: @@ -519,7 +522,7 @@ ClangASTType::GetFormat (clang_type_t clang_type) break; case clang::Type::ConstantArray: - break; + return lldb::eFormatVoid; // no value case clang::Type::ExtVector: case clang::Type::Vector: @@ -597,12 +600,13 @@ ClangASTType::GetFormat (clang_type_t clang_type) return ClangASTType::GetFormat(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); case clang::Type::Auto: return ClangASTType::GetFormat(llvm::cast<clang::AutoType>(qual_type)->desugar().getAsOpaquePtr()); + case clang::Type::Paren: + return ClangASTType::GetFormat(llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()); case clang::Type::Elaborated: return ClangASTType::GetFormat(llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: - case clang::Type::Paren: case clang::Type::Attributed: case clang::Type::TemplateTypeParm: case clang::Type::SubstTemplateTypeParm: @@ -950,6 +954,31 @@ ClangASTType::DumpValue depth); // Scope depth for any types that have children } break; + + case clang::Type::Paren: + { + clang::QualType desugar_qual_type = llvm::cast<clang::ParenType>(qual_type)->desugar(); + lldb::Format desugar_format = ClangASTType::GetFormat(desugar_qual_type.getAsOpaquePtr()); + std::pair<uint64_t, unsigned> desugar_type_info = ast_context->getTypeInfo(desugar_qual_type); + uint64_t desugar_byte_size = desugar_type_info.first / 8; + + return DumpValue (ast_context, // The clang AST context for this type + desugar_qual_type.getAsOpaquePtr(), // The clang type we want to dump + exe_ctx, + s, // Stream to dump to + desugar_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + data_byte_offset, // Offset into "data" where to grab value from + desugar_byte_size, // Size of this type in bytes + bitfield_bit_size, // Bitfield bit size + bitfield_bit_offset,// Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth); // Scope depth for any types that have children + } + break; + default: // We are down the a scalar type that we just need to display. data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset); @@ -1390,6 +1419,12 @@ ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, clang_type_t s); return; + case clang::Type::Paren: + DumpTypeDescription (ast_context, + llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr(), + s); + return; + case clang::Type::Record: { ClangASTContext::GetCompleteType (ast_context, clang_type); diff --git a/lldb/test/functionalities/data-formatter/rdar-13338477/Makefile b/lldb/test/functionalities/data-formatter/rdar-13338477/Makefile new file mode 100644 index 00000000000..314f1cb2f07 --- /dev/null +++ b/lldb/test/functionalities/data-formatter/rdar-13338477/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/test/functionalities/data-formatter/rdar-13338477/Test-rdar-13338477.py b/lldb/test/functionalities/data-formatter/rdar-13338477/Test-rdar-13338477.py new file mode 100644 index 00000000000..6f68df96106 --- /dev/null +++ b/lldb/test/functionalities/data-formatter/rdar-13338477/Test-rdar-13338477.py @@ -0,0 +1,70 @@ +""" +Test lldb data formatter subsystem. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * +import lldbutil + +class Radar13338477DataFormatterTestCase(TestBase): + + # test for rdar://problem/13338477 () + mydir = os.path.join("functionalities", "data-formatter", "rdar-13338477") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @dsym_test + def test_with_dsym_and_run_command(self): + """Test that LLDB handles the clang typeclass Paren correctly.""" + self.buildDsym() + self.data_formatter_commands() + + @dwarf_test + def test_with_dwarf_and_run_command(self): + """Test that LLDB handles the clang typeclass Paren correctly.""" + self.buildDwarf() + self.data_formatter_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break at. + self.line = line_number('main.cpp', '// Set break point at this line.') + + def data_formatter_commands(self): + """Test that LLDB handles the clang typeclass Paren correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # This is the function to remove the custom formats in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type format delete hex', check=False) + self.runCmd('type summary clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.expect('p *(int (*)[3])foo', + substrs = ['(int [3]) $',' = {','[0] = 1','[1] = 2','[2] = 3']) + + self.expect('p *(int (*)[3])foo', matching=False, + substrs = ['01 00 00 00 02 00 00 00 03 00 00 00']) + self.expect('p *(int (*)[3])foo', matching=False, + substrs = ['0x000000030000000200000001']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() diff --git a/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp b/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp new file mode 100644 index 00000000000..b05c7d4d837 --- /dev/null +++ b/lldb/test/functionalities/data-formatter/rdar-13338477/main.cpp @@ -0,0 +1,17 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +void bar(int const *foo) { + __builtin_trap(); // Set break point at this line. +} + +int main() { + int foo[] = {1,2,3}; + bar(foo); +} |