Added support for objective C built-in types: id, Class, and SEL. This
involved watching for the objective C built-in types in DWARF and making sure
when we convert the DWARF types into clang types that we use the appropriate
ASTContext types.
Added a way to find and dump types in lldb (something equivalent to gdb's
"ptype" command):
image lookup --type <TYPENAME>
This only works for looking up types by name and won't work with variables.
It also currently dumps out verbose internal information. I will modify it
to dump more appropriate user level info in my next submission.
Hookup up the "FindTypes()" functions in the SymbolFile and SymbolVendor so
we can lookup types by name in one or more images.
Fixed "image lookup --address <ADDRESS>" to be able to correctly show all
symbol context information, but it will only show this extra information when
the new "--verbose" flag is used.
Updated to latest LLVM to get a few needed fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@110089 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 10c5a2e..140ecba 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -657,12 +657,30 @@
}
void *
-ClangASTContext::GetVoidBuiltInType()
+ClangASTContext::GetBuiltInType_void()
{
return getASTContext()->VoidTy.getAsOpaquePtr();
}
void *
+ClangASTContext::GetBuiltInType_objc_id()
+{
+ return getASTContext()->getObjCIdType().getAsOpaquePtr();
+}
+
+void *
+ClangASTContext::GetBuiltInType_objc_Class()
+{
+ return getASTContext()->getObjCClassType().getAsOpaquePtr();
+}
+
+void *
+ClangASTContext::GetBuiltInType_objc_selector()
+{
+ return getASTContext()->getObjCSelType().getAsOpaquePtr();
+}
+
+void *
ClangASTContext::GetCStringType (bool is_const)
{
QualType char_type(getASTContext()->CharTy);
@@ -1176,7 +1194,6 @@
case clang::Type::Record:
case clang::Type::ObjCObject:
case clang::Type::ObjCInterface:
- case clang::Type::ObjCObjectPointer:
return true;
case clang::Type::Typedef:
@@ -1200,6 +1217,19 @@
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
switch (type_class)
{
+ case clang::Type::Builtin:
+ switch (cast<clang::BuiltinType>(qual_type)->getKind())
+ {
+ case clang::BuiltinType::ObjCId: // Child is Class
+ case clang::BuiltinType::ObjCClass: // child is Class
+ case clang::BuiltinType::ObjCSel: // child is const char *
+ num_children = 1;
+
+ default:
+ break;
+ }
+ break;
+
case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
@@ -1272,8 +1302,18 @@
break;
case clang::Type::ObjCObjectPointer:
- return ClangASTContext::GetNumChildren (cast<ObjCObjectPointerType>(qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
- omit_empty_base_classes);
+ {
+ ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(qual_type.getTypePtr());
+ QualType pointee_type = pointer_type->getPointeeType();
+ uint32_t num_pointee_children = ClangASTContext::GetNumChildren (pointee_type.getAsOpaquePtr(),
+ omit_empty_base_classes);
+ // If this type points to a simple type, then it has 1 child
+ if (num_pointee_children == 0)
+ num_children = 1;
+ else
+ num_children = num_pointee_children;
+ }
+ break;
case clang::Type::ConstantArray:
num_children = cast<ConstantArrayType>(qual_type.getTypePtr())->getSize().getLimitedValue();
@@ -1362,6 +1402,27 @@
QualType parent_qual_type(QualType::getFromOpaquePtr(parent_clang_type));
switch (parent_qual_type->getTypeClass())
{
+ case clang::Type::Builtin:
+ switch (cast<clang::BuiltinType>(parent_qual_type)->getKind())
+ {
+ case clang::BuiltinType::ObjCId:
+ case clang::BuiltinType::ObjCClass:
+ return ast_context->ObjCBuiltinClassTy.getAsOpaquePtr();
+
+ case clang::BuiltinType::ObjCSel:
+ {
+ QualType char_type(ast_context->CharTy);
+ char_type.addConst();
+ return ast_context->getPointerType(char_type).getAsOpaquePtr();
+ }
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+
case clang::Type::Record:
{
const RecordType *record_type = cast<RecordType>(parent_qual_type.getTypePtr());
@@ -1468,7 +1529,7 @@
{
if (omit_empty_base_classes)
{
- if (ClangASTContext::GetNumChildren(superclass_interface_decl, omit_empty_base_classes) > 0)
+ if (ClangASTContext::GetNumChildren(ast_context->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr(), omit_empty_base_classes) > 0)
{
if (idx == 0)
{
@@ -1480,10 +1541,7 @@
std::pair<uint64_t, unsigned> ivar_type_info = ast_context->getTypeInfo(ivar_qual_type.getTypePtr());
child_byte_size = ivar_type_info.first / 8;
-
- // Figure out the field offset within the current struct/union/class type
- bit_offset = interface_layout.getFieldOffset (child_idx);
- child_byte_offset = bit_offset / 8;
+ child_byte_offset = 0;
return ivar_qual_type.getAsOpaquePtr();
}
@@ -1494,6 +1552,8 @@
else
++child_idx;
}
+
+ const uint32_t superclass_idx = child_idx;
if (idx < (child_idx + class_interface_decl->ivar_size()))
{
@@ -1514,7 +1574,7 @@
child_byte_size = ivar_type_info.first / 8;
// Figure out the field offset within the current struct/union/class type
- bit_offset = interface_layout.getFieldOffset (child_idx);
+ bit_offset = interface_layout.getFieldOffset (child_idx - superclass_idx);
child_byte_offset = bit_offset / 8;
return ivar_qual_type.getAsOpaquePtr();
@@ -1529,17 +1589,41 @@
case clang::Type::ObjCObjectPointer:
{
- return GetChildClangTypeAtIndex (ast_context,
- parent_name,
- cast<ObjCObjectPointerType>(parent_qual_type.getTypePtr())->getPointeeType().getAsOpaquePtr(),
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- child_name,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset);
+ ObjCObjectPointerType *pointer_type = cast<ObjCObjectPointerType>(parent_qual_type.getTypePtr());
+ QualType pointee_type = pointer_type->getPointeeType();
+
+ if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr()))
+ {
+ return GetChildClangTypeAtIndex (ast_context,
+ parent_name,
+ pointer_type->getPointeeType().getAsOpaquePtr(),
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ child_name,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset);
+ }
+ else
+ {
+ if (parent_name)
+ {
+ child_name.assign(1, '*');
+ child_name += parent_name;
+ }
+
+ // We have a pointer to an simple type
+ if (idx == 0)
+ {
+ std::pair<uint64_t, unsigned> clang_type_info = ast_context->getTypeInfo(pointee_type);
+ assert(clang_type_info.first % 8 == 0);
+ child_byte_size = clang_type_info.first / 8;
+ child_byte_offset = 0;
+ return pointee_type.getAsOpaquePtr();
+ }
+ }
}
break;
@@ -2688,22 +2772,6 @@
return false;
}
-size_t
-ClangASTContext::GetTypeBitSize (clang::ASTContext *ast_context, void *clang_type)
-{
- if (clang_type)
- return ast_context->getTypeSize(QualType::getFromOpaquePtr(clang_type));
- return 0;
-}
-
-size_t
-ClangASTContext::GetTypeBitAlign (clang::ASTContext *ast_context, void *clang_type)
-{
- if (clang_type)
- return ast_context->getTypeAlign(QualType::getFromOpaquePtr(clang_type));
- return 0;
-}
-
bool
ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed)
{