Fixed the forward declaration issue that was present in the DWARF parser after
adding methods to C++ and objective C classes. In order to make methods, we
need the function prototype which means we need the arguments. Parsing these
could cause a circular reference that caused an assertion.
Added a new typedef for the clang opaque types which are just void pointers:
lldb::clang_type_t. This appears in lldb-types.h.
This was fixed by enabling struct, union, class, and enum types to only get
a forward declaration when we make the clang opaque qual type for these
types. When they need to actually be resolved, lldb_private::Type will call
a new function in the SymbolFile protocol to resolve a clang type when it is
not fully defined (clang::TagDecl::getDefinition() returns NULL). This allows
us to be a lot more lazy when parsing clang types and keeps down the amount
of data that gets parsed into the ASTContext for each module.
Getting the clang type from a "lldb_private::Type" object now takes a boolean
that indicates if a forward declaration is ok:
clang_type_t lldb_private::Type::GetClangType (bool forward_decl_is_ok);
So function prototypes that define parameters that are "const T&" can now just
parse the forward declaration for type 'T' and we avoid circular references in
the type system.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115012 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index 4b437f4..6f63f53 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -241,7 +241,7 @@
SBValue::GetOpaqueType()
{
if (m_opaque_sp)
- return m_opaque_sp->GetOpaqueClangQualType();
+ return m_opaque_sp->GetClangType();
return NULL;
}
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index 5250ab5..26c2ace 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -360,7 +360,7 @@
{
const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope);
- const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetOpaqueClangQualType());
+ const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType());
if (val_cstr)
s.PutCString(val_cstr);
@@ -384,7 +384,7 @@
if (is_aggregate)
s.PutChar('{');
- bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetOpaqueClangQualType());
+ bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType());
if (is_ptr_or_ref && ptr_depth == 0)
return;
diff --git a/source/Commands/CommandObjectImage.cpp b/source/Commands/CommandObjectImage.cpp
index 8c17221..30e9195 100644
--- a/source/Commands/CommandObjectImage.cpp
+++ b/source/Commands/CommandObjectImage.cpp
@@ -429,7 +429,7 @@
{
// Resolve the clang type so that any forward references
// to types that haven't yet been parsed will get parsed.
- type_sp->GetOpaqueClangQualType ();
+ type_sp->GetClangType ();
type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
}
strm.EOL();
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index 8ccb67c..de6500e 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -417,10 +417,10 @@
}
void *
-Value::GetOpaqueClangQualType ()
+Value::GetClangType ()
{
if (m_context_type == eContextTypeValue)
- return ((Value*)m_context)->GetOpaqueClangQualType();
+ return ((Value*)m_context)->GetClangType();
switch (m_context_type)
{
@@ -436,12 +436,12 @@
case eContextTypeDCType:
if (GetType())
- return GetType()->GetOpaqueClangQualType();
+ return GetType()->GetClangType();
break;
case eContextTypeDCVariable:
if (GetVariable())
- return GetVariable()->GetType()->GetOpaqueClangQualType();
+ return GetVariable()->GetType()->GetClangType();
break;
}
@@ -669,7 +669,7 @@
if (m_context_type == eContextTypeOpaqueClangQualType)
{
- void *opaque_clang_qual_type = GetOpaqueClangQualType();
+ void *opaque_clang_qual_type = GetClangType();
switch (m_value_type)
{
case eValueTypeScalar: // raw scalar value
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index e98e552..ae53a83 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -263,7 +263,7 @@
{
bool omit_empty_base_classes = true;
return ClangASTContext::GetIndexOfChildWithName (GetClangAST(),
- GetOpaqueClangQualType(),
+ GetClangType(),
name.AsCString(),
omit_empty_base_classes);
}
@@ -276,7 +276,7 @@
// need a vector of indexes that can get us down to the correct child
std::vector<uint32_t> child_indexes;
clang::ASTContext *clang_ast = GetClangAST();
- void *clang_type = GetOpaqueClangQualType();
+ void *clang_type = GetClangType();
bool omit_empty_base_classes = true;
const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast,
clang_type,
@@ -349,7 +349,7 @@
uint32_t child_bitfield_bit_offset = 0;
const bool transparent_pointers = synthetic_array_member == false;
clang::ASTContext *clang_ast = GetClangAST();
- void *clang_type = GetOpaqueClangQualType();
+ void *clang_type = GetClangType();
void *child_clang_type;
child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast,
GetName().AsCString(),
@@ -390,7 +390,7 @@
{
if (m_summary_str.empty())
{
- void *clang_type = GetOpaqueClangQualType();
+ void *clang_type = GetClangType();
// See if this is a pointer to a C string?
uint32_t fixed_length = 0;
@@ -561,7 +561,7 @@
ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
{
// If our byte size is zero this is an aggregate type that has children
- if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType()) == false)
+ if (ClangASTContext::IsAggregateType (GetClangType()) == false)
{
if (UpdateValueIfNeeded(exe_scope))
{
@@ -575,7 +575,7 @@
case Value::eContextTypeDCType:
case Value::eContextTypeDCVariable:
{
- void *clang_type = GetOpaqueClangQualType ();
+ void *clang_type = GetClangType ();
if (clang_type)
{
StreamString sstr;
@@ -665,7 +665,7 @@
return false;
uint32_t count = 0;
- lldb::Encoding encoding = ClangASTType::GetEncoding (GetOpaqueClangQualType(), count);
+ lldb::Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count);
char *end = NULL;
const size_t byte_size = GetByteSize();
@@ -717,7 +717,7 @@
m_data.SetByteOrder(eByteOrderHost);
const size_t converted_byte_size = ClangASTContext::ConvertStringToFloatValue (
GetClangAST(),
- GetOpaqueClangQualType(),
+ GetClangType(),
value_str,
dst,
byte_size);
@@ -756,7 +756,7 @@
lldb::LanguageType
ValueObject::GetObjectRuntimeLanguage ()
{
- void *opaque_qual_type = GetOpaqueClangQualType();
+ void *opaque_qual_type = GetClangType();
if (opaque_qual_type == NULL)
return lldb::eLanguageTypeC;
@@ -805,13 +805,13 @@
bool
ValueObject::IsPointerType ()
{
- return ClangASTContext::IsPointerType (GetOpaqueClangQualType());
+ return ClangASTContext::IsPointerType (GetClangType());
}
bool
ValueObject::IsPointerOrReferenceType ()
{
- return ClangASTContext::IsPointerOrReferenceType(GetOpaqueClangQualType());
+ return ClangASTContext::IsPointerOrReferenceType(GetClangType());
}
ValueObjectSP
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index 73af56c..0398682 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -52,7 +52,7 @@
}
void *
-ValueObjectChild::GetOpaqueClangQualType()
+ValueObjectChild::GetClangType()
{
return m_clang_type;
}
@@ -104,7 +104,7 @@
{
if (m_type_name.IsEmpty())
{
- m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType());
+ m_type_name = ClangASTType::GetClangTypeName (GetClangType());
if (m_type_name)
{
if (m_bitfield_bit_size > 0)
@@ -139,13 +139,13 @@
Value::ValueType value_type = parent->GetValue().GetValueType();
m_value.SetValueType (value_type);
- if (ClangASTContext::IsPointerOrReferenceType (parent->GetOpaqueClangQualType()))
+ if (ClangASTContext::IsPointerOrReferenceType (parent->GetClangType()))
{
uint32_t offset = 0;
m_value.GetScalar() = parent->GetDataExtractor().GetPointer(&offset);
// For pointers, m_byte_offset should only ever be set if we
// ValueObject::GetSyntheticArrayMemberFromPointer() was called
- if (ClangASTContext::IsPointerType (parent->GetOpaqueClangQualType()) && m_byte_offset)
+ if (ClangASTContext::IsPointerType (parent->GetClangType()) && m_byte_offset)
m_value.GetScalar() += m_byte_offset;
if (value_type == Value::eValueTypeScalar ||
value_type == Value::eValueTypeFileAddress)
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 5d5215f..ff3dac8 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/source/Core/ValueObjectRegister.cpp
@@ -43,7 +43,7 @@
}
void *
-ValueObjectRegisterContext::GetOpaqueClangQualType ()
+ValueObjectRegisterContext::GetClangType ()
{
return NULL;
}
@@ -120,7 +120,7 @@
}
void *
-ValueObjectRegisterSet::GetOpaqueClangQualType ()
+ValueObjectRegisterSet::GetClangType ()
{
return NULL;
}
@@ -228,7 +228,7 @@
}
void *
-ValueObjectRegister::GetOpaqueClangQualType ()
+ValueObjectRegister::GetClangType ()
{
if (m_clang_type == NULL && m_reg_info)
{
@@ -251,7 +251,7 @@
ValueObjectRegister::GetTypeName()
{
if (m_type_name.IsEmpty())
- m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType());
+ m_type_name = ClangASTType::GetClangTypeName (GetClangType());
return m_type_name;
}
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index cf465fb..759b5ce 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -46,11 +46,11 @@
}
void *
-ValueObjectVariable::GetOpaqueClangQualType ()
+ValueObjectVariable::GetClangType ()
{
Type *var_type = m_variable_sp->GetType();
if (var_type)
- return var_type->GetOpaqueClangQualType();
+ return var_type->GetClangType();
return NULL;
}
@@ -172,7 +172,7 @@
}
}
- if (ClangASTContext::IsAggregateType (GetOpaqueClangQualType()))
+ if (ClangASTContext::IsAggregateType (GetClangType()))
{
// this value object represents an aggregate type whose
// children have values, but this object does not. So we
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index d1d576f..43c4150 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -709,7 +709,7 @@
if (type->GetASTContext() == var->GetType()->GetClangAST())
{
- if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType()))
+ if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType()))
return NULL;
}
else
@@ -759,7 +759,7 @@
if (!this_type)
return;
- TypeFromUser this_user_type(this_type->GetOpaqueClangQualType(),
+ TypeFromUser this_user_type(this_type->GetClangType(),
this_type->GetClangAST());
m_object_pointer_type = this_user_type;
@@ -836,7 +836,7 @@
if (type.get())
{
- TypeFromUser user_type(type->GetOpaqueClangQualType(),
+ TypeFromUser user_type(type->GetClangType(),
type->GetClangAST());
AddOneType(context, user_type, false);
@@ -866,7 +866,7 @@
return NULL;
}
- void *var_opaque_type = var_type->GetOpaqueClangQualType();
+ void *var_opaque_type = var_type->GetClangType();
if (!var_opaque_type)
{
@@ -1043,7 +1043,7 @@
return;
}
- fun_opaque_type = fun_type->GetOpaqueClangQualType();
+ fun_opaque_type = fun_type->GetClangType();
if (!fun_opaque_type)
{
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
index 88e78da..37fc6c2 100644
--- a/source/Expression/ClangExpressionVariable.cpp
+++ b/source/Expression/ClangExpressionVariable.cpp
@@ -97,7 +97,7 @@
if (format == lldb::eFormatDefault)
format = val.GetValueDefaultFormat ();
- void *clang_type = val.GetOpaqueClangQualType ();
+ void *clang_type = val.GetClangType ();
output_stream.Printf("%s = ", m_name.c_str());
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index 4035479..aaff16d 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -83,7 +83,7 @@
m_JITted (false)
{
m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
- m_function_return_qual_type = m_function_ptr->GetReturnType().GetOpaqueClangQualType();
+ m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType();
}
//----------------------------------------------------------------------
@@ -153,7 +153,7 @@
else
{
Value *arg_value = m_arg_values.GetValueAtIndex(i);
- void *clang_qual_type = arg_value->GetOpaqueClangQualType ();
+ void *clang_qual_type = arg_value->GetClangType ();
if (clang_qual_type != NULL)
{
type_stdstr = ClangASTContext::GetTypeName(clang_qual_type);
@@ -322,7 +322,7 @@
if (arg_value->GetValueType() == Value::eValueTypeHostAddress &&
arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType &&
- ClangASTContext::IsPointerType(arg_value->GetOpaqueClangQualType()))
+ ClangASTContext::IsPointerType(arg_value->GetClangType()))
continue;
const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext());
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index a29994e..eef35a1 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -2136,7 +2136,7 @@
return false;
}
- void *array_type = array_val.GetOpaqueClangQualType();
+ void *array_type = array_val.GetClangType();
void *member_type;
uint64_t size = 0;
@@ -2214,7 +2214,7 @@
{
case Value::eContextTypeOpaqueClangQualType:
{
- void *clang_type = stack.back().GetOpaqueClangQualType();
+ void *clang_type = stack.back().GetClangType();
if (ClangASTContext::IsAggregateType (clang_type))
{
@@ -2434,7 +2434,7 @@
return false;
}
- void *ptr_type = tmp.GetOpaqueClangQualType();
+ void *ptr_type = tmp.GetClangType();
void *target_type;
if (!ClangASTContext::IsPointerType(ptr_type, &target_type))
@@ -2483,7 +2483,7 @@
Value *proxy = expr_local_variable->CreateProxy();
stack.push_back(*proxy);
delete proxy;
- //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetOpaqueClangQualType());
+ //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetClangType());
*/
}
break;
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 2fe0b78..21adec8 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -236,7 +236,7 @@
return false;
case Value::eContextTypeOpaqueClangQualType:
{
- void *val_type = val->GetOpaqueClangQualType();
+ void *val_type = val->GetClangType();
uint32_t cstr_length;
if (ClangASTContext::IsCStringType (val_type, cstr_length))
@@ -435,7 +435,7 @@
return false;
case Value::eContextTypeOpaqueClangQualType:
{
- void *value_type = value->GetOpaqueClangQualType();
+ void *value_type = value->GetClangType();
bool is_signed;
if (ClangASTContext::IsIntegerType (value_type, is_signed))
@@ -484,7 +484,7 @@
RegisterContext *reg_ctx = thread.GetRegisterContext();
- void *value_type = value.GetOpaqueClangQualType();
+ void *value_type = value.GetClangType();
bool is_signed;
if (ClangASTContext::IsIntegerType (value_type, is_signed))
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index ba662e2..ba7f06c 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -266,7 +266,7 @@
return false;
case Value::eContextTypeOpaqueClangQualType:
{
- void *value_type = value->GetOpaqueClangQualType();
+ void *value_type = value->GetClangType();
bool is_signed;
if (ClangASTContext::IsIntegerType (value_type, is_signed))
@@ -309,7 +309,7 @@
return false;
case Value::eContextTypeOpaqueClangQualType:
{
- void *value_type = value.GetOpaqueClangQualType();
+ void *value_type = value.GetClangType();
bool is_signed;
RegisterContext *reg_ctx = thread.GetRegisterContext();
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp
index 7ba7a9b..346dc54 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp
@@ -51,7 +51,7 @@
assert (m_process == exe_ctx.process);
// ObjC objects can only be pointers:
- if (!ClangASTContext::IsPointerType (object.GetOpaqueClangQualType()))
+ if (!ClangASTContext::IsPointerType (object.GetClangType()))
return NULL;
// Get the function address for the print function.
@@ -63,7 +63,7 @@
Scalar scalar;
if (!ClangASTType::GetValueAsScalar (object.GetClangAST(),
- object.GetOpaqueClangQualType(),
+ object.GetClangType(),
object.GetDataExtractor(),
0,
object.GetByteSize(),
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 79861d6..31e313d 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1007,10 +1007,9 @@
SymbolFileDWARF::ParseChildMembers
(
const SymbolContext& sc,
- TypeSP& type_sp,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die,
- void *class_clang_type,
+ clang_type_t class_clang_type,
const LanguageType class_language,
std::vector<clang::CXXBaseSpecifier *>& base_classes,
std::vector<int>& member_accessibilities,
@@ -1098,7 +1097,7 @@
accessibility = default_accessibility;
member_accessibilities.push_back(accessibility);
- type_list->GetClangASTContext().AddFieldToRecordType (type_sp->GetOpaqueClangQualType(), name, member_type->GetOpaqueClangQualType(), accessibility, bit_size);
+ type_list->GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size);
}
}
break;
@@ -1170,11 +1169,11 @@
if (class_language == eLanguageTypeObjC)
{
- type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetOpaqueClangQualType());
+ type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType());
}
else
{
- base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class));
+ base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class));
assert(base_classes.back());
}
}
@@ -1217,6 +1216,124 @@
return NULL;
}
+lldb::clang_type_t
+SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type)
+{
+ // We have a struct/union/class/enum that needs to be fully resolved.
+ const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type);
+ assert (die);
+ if (die == NULL)
+ return NULL;
+
+ DWARFCompileUnit *cu = DebugInfo()->GetCompileUnitContainingDIE (die->GetOffset()).get();
+ Type *type = m_die_to_type.lookup (die);
+
+ const dw_tag_t tag = die->Tag();
+
+ assert (clang_type);
+ DWARFDebugInfoEntry::Attributes attributes;
+
+ TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
+
+ switch (tag)
+ {
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_class_type:
+ type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
+ if (die->HasChildren())
+ {
+ LanguageType class_language = eLanguageTypeUnknown;
+ if (ClangASTContext::IsObjCClassType (clang_type))
+ class_language = eLanguageTypeObjC;
+
+ int tag_decl_kind = -1;
+ AccessType default_accessibility = eAccessNone;
+ if (tag == DW_TAG_structure_type)
+ {
+ tag_decl_kind = clang::TTK_Struct;
+ default_accessibility = eAccessPublic;
+ }
+ else if (tag == DW_TAG_union_type)
+ {
+ tag_decl_kind = clang::TTK_Union;
+ default_accessibility = eAccessPublic;
+ }
+ else if (tag == DW_TAG_class_type)
+ {
+ tag_decl_kind = clang::TTK_Class;
+ default_accessibility = eAccessPrivate;
+ }
+
+ SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
+ std::vector<clang::CXXBaseSpecifier *> base_classes;
+ std::vector<int> member_accessibilities;
+ bool is_a_class = false;
+ ParseChildMembers (sc,
+ cu,
+ die,
+ clang_type,
+ class_language,
+ base_classes,
+ member_accessibilities,
+ default_accessibility,
+ is_a_class);
+
+ // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
+ // need to tell the clang type it is actually a class.
+ if (class_language != eLanguageTypeObjC)
+ {
+ if (is_a_class && tag_decl_kind != clang::TTK_Class)
+ type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class);
+ }
+
+ // Since DW_TAG_structure_type gets used for both classes
+ // and structures, we may need to set any DW_TAG_member
+ // fields to have a "private" access if none was specified.
+ // When we parsed the child members we tracked that actual
+ // accessibility value for each DW_TAG_member in the
+ // "member_accessibilities" array. If the value for the
+ // member is zero, then it was set to the "default_accessibility"
+ // which for structs was "public". Below we correct this
+ // by setting any fields to "private" that weren't correctly
+ // set.
+ if (is_a_class && !member_accessibilities.empty())
+ {
+ // This is a class and all members that didn't have
+ // their access specified are private.
+ type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size());
+ }
+
+ if (!base_classes.empty())
+ {
+ type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size());
+
+ // Clang will copy each CXXBaseSpecifier in "base_classes"
+ // so we have to free them all.
+ ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size());
+ }
+
+ }
+ type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+ return clang_type;
+
+ case DW_TAG_enumeration_type:
+ type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
+ if (die->HasChildren())
+ {
+ SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
+ ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die);
+ }
+ type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+ return clang_type;
+
+ default:
+ assert(false && "not a forward clang type decl!");
+ break;
+ }
+ return NULL;
+}
+
Type*
SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die)
{
@@ -1224,10 +1341,7 @@
{
Type *type = m_die_to_type.lookup (type_die);
if (type == NULL)
- {
- TypeSP owning_type_sp;
- type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get();
- }
+ type = GetTypeForDIE (cu, type_die).get();
assert (type != DIE_IS_BEING_PARSED);
return type;
}
@@ -1889,7 +2003,7 @@
const DWARFDebugInfoEntry *parent_die,
bool skip_artificial,
TypeList* type_list,
- std::vector<void *>& function_param_types,
+ std::vector<clang_type_t>& function_param_types,
std::vector<clang::ParmVarDecl*>& function_param_decls
)
{
@@ -1983,9 +2097,9 @@
Type *type = ResolveTypeUID(param_type_die_offset);
if (type)
{
- function_param_types.push_back (type->GetOpaqueClangQualType());
+ function_param_types.push_back (type->GetClangType(true));
- clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetOpaqueClangQualType(), storage);
+ clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangType(), storage);
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);
}
@@ -2005,8 +2119,7 @@
SymbolFileDWARF::ParseChildEnumerators
(
const SymbolContext& sc,
- TypeSP& type_sp,
- void * enumerator_qual_type,
+ clang_type_t enumerator_clang_type,
uint32_t enumerator_byte_size,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *parent_die
@@ -2065,7 +2178,12 @@
if (name && name[0] && got_value)
{
TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
- type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (type_sp->GetOpaqueClangQualType(), enumerator_qual_type, decl, name, enum_value, enumerator_byte_size * 8);
+ type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type,
+ enumerator_clang_type,
+ decl,
+ name,
+ enum_value,
+ enumerator_byte_size * 8);
++enumerators_added;
}
}
@@ -2194,8 +2312,6 @@
break;
default:
- //printf("0x%8.8x: %-30s skipping attribute at 0x%8.8x: %s\n", die->GetOffset(), DW_TAG_value_to_name(tag), attributes.die_offsets[i], DW_AT_value_to_name(attr)); // remove this, debug only
-
case DW_AT_abstract_origin:
case DW_AT_accessibility:
case DW_AT_allocated:
@@ -2225,14 +2341,7 @@
}
TypeSP
-SymbolFileDWARF::GetTypeForDIE
-(
- DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry* die,
- TypeSP& owning_type_sp,
- int32_t child_type,
- uint32_t idx
-)
+SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die)
{
TypeSP type_sp;
if (die != NULL)
@@ -2242,10 +2351,7 @@
if (type_ptr == NULL)
{
SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
- bool type_is_new = false;
- type_sp = ParseType(sc, cu, die, type_is_new);
- if (owning_type_sp.get() == NULL)
- owning_type_sp = type_sp;
+ type_sp = ParseType(sc, cu, die, NULL);
}
else if (type_ptr != DIE_IS_BEING_PARSED)
{
@@ -2316,17 +2422,21 @@
}
TypeSP
-SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new)
+SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr)
{
TypeSP type_sp;
+ if (type_is_new_ptr)
+ *type_is_new_ptr = false;
+
AccessType accessibility = eAccessNone;
if (die != NULL)
{
Type *type_ptr = m_die_to_type.lookup (die);
if (type_ptr == NULL)
{
- type_is_new = true;
+ if (type_is_new_ptr)
+ *type_is_new_ptr = true;
const dw_tag_t tag = die->Tag();
@@ -2335,7 +2445,7 @@
const char *type_name_cstr = NULL;
ConstString type_name_dbstr;
Type::EncodingUIDType encoding_uid_type = Type::eIsTypeWithUID;
- void *clang_type = NULL;
+ clang_type_t clang_type = NULL;
TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
dw_attr_t attr;
@@ -2350,7 +2460,6 @@
case DW_TAG_restrict_type:
case DW_TAG_volatile_type:
{
- //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
@@ -2398,37 +2507,37 @@
case DW_TAG_pointer_type:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::ePointerToTypeWithUID;
break;
case DW_TAG_reference_type:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::eLValueReferenceToTypeWithUID;
break;
case DW_TAG_typedef:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::eTypedefToTypeWithUID;
break;
case DW_TAG_const_type:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::eIsConstTypeWithUID; //ClangASTContext::AddConstModifier (clang_type);
break;
case DW_TAG_restrict_type:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::eIsRestrictTypeWithUID; //ClangASTContext::AddRestrictModifier (clang_type);
break;
case DW_TAG_volatile_type:
// The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetOpaqueClangQualType()
+ // Type object and will be looked up when the Type::GetClangType()
encoding_uid_type = Type::eIsVolatileTypeWithUID; //ClangASTContext::AddVolatileModifier (clang_type);
break;
}
@@ -2473,7 +2582,6 @@
case DW_TAG_union_type:
case DW_TAG_class_type:
{
- //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
@@ -2559,21 +2667,34 @@
}
assert (tag_decl_kind != -1);
- clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language);
+ bool clang_type_was_created = false;
+ clang_type = m_forward_decl_die_to_clang_type.lookup (die);
+ if (clang_type == NULL)
+ {
+ clang_type_was_created = true;
+ clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language);
+ }
// Store a forward declaration to this class type in case any
// parameters in any class methods need it for the clang
// types for function prototypes.
- m_die_to_clang_type[die] = clang_type;
m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type));
m_die_to_type[die] = type_sp.get();
-// assert(type_sp.get());
-// if (accessibility)
-// type_sp->SetAccess(accessibility);
-//
+ // Leave this as a forward declaration until we need
+ // to know the details of the type. lldb_private::Type
+ // will automatically call the SymbolFile virtual function
+ // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
+ // When the definition needs to be defined.
+ if (clang_type_was_created)
+ {
+ m_forward_decl_die_to_clang_type[die] = clang_type;
+ m_forward_decl_clang_type_to_die[clang_type] = die;
+ }
+
+#if 0
type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
if (die->HasChildren())
{
@@ -2581,7 +2702,6 @@
std::vector<int> member_accessibilities;
bool is_a_class = false;
ParseChildMembers (sc,
- type_sp,
dwarf_cu,
die,
clang_type,
@@ -2627,12 +2747,12 @@
}
type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+#endif // #if 0
}
break;
case DW_TAG_enumeration_type:
{
- //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
@@ -2679,21 +2799,41 @@
}
}
}
-
- void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8);
- clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type);
+ clang_type_t enumerator_clang_type = NULL;
+ clang_type = m_forward_decl_die_to_clang_type.lookup (die);
+ if (clang_type == NULL)
+ {
+ enumerator_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8);
+ clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_clang_type);
+ }
+ else
+ {
+ enumerator_clang_type = ClangASTContext::GetEnumerationIntegerType (clang_type);
+ assert (enumerator_clang_type != NULL);
+ }
+
m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type));
m_die_to_type[die] = type_sp.get();
+ // Leave this as a forward declaration until we need
+ // to know the details of the type. lldb_private::Type
+ // will automatically call the SymbolFile virtual function
+ // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
+ // When the definition needs to be defined.
+ m_forward_decl_die_to_clang_type[die] = clang_type;
+ m_forward_decl_clang_type_to_die[clang_type] = die;
+
+#if 0
if (die->HasChildren())
{
type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
- ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die);
+ ParseChildEnumerators(sc, enumerator_clang_type, byte_size, dwarf_cu, die);
type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
}
+#endif // #if 0
}
}
break;
@@ -2702,7 +2842,6 @@
case DW_TAG_subprogram:
case DW_TAG_subroutine_type:
{
- //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
@@ -2787,14 +2926,14 @@
}
}
- void *return_clang_type = NULL;
+ clang_type_t return_clang_type = NULL;
Type *func_type = ResolveTypeUID(type_die_offset);
if (func_type)
- return_clang_type = func_type->GetOpaqueClangQualType();
+ return_clang_type = func_type->GetClangType(true);
else
return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
- std::vector<void *> function_param_types;
+ std::vector<clang_type_t> function_param_types;
std::vector<clang::ParmVarDecl*> function_param_decls;
// Parse the function children for the parameters
@@ -2817,7 +2956,7 @@
const char *class_name_start = type_name_cstr + 2;
const char *class_name_end = ::strchr (class_name_start, ' ');
SymbolContext empty_sc;
- void *class_opaque_type = NULL;
+ clang_type_t class_opaque_type = NULL;
if (class_name_start < class_name_end)
{
ConstString class_name (class_name_start, class_name_end - class_name_start);
@@ -2828,9 +2967,9 @@
for (uint32_t i=0; i<match_count; ++i)
{
Type *type = types.GetTypeAtIndex (i).get();
- if (ClangASTContext::IsObjCClassType (type->GetOpaqueClangQualType()))
+ if (ClangASTContext::IsObjCClassType (type->GetClangType()))
{
- class_opaque_type = type->GetOpaqueClangQualType();
+ class_opaque_type = type->GetClangType();
break;
}
}
@@ -2856,7 +2995,7 @@
Type *class_type = ResolveType (dwarf_cu, parent_die);
if (class_type)
{
- void *class_opaque_type = class_type->GetOpaqueClangQualType ();
+ clang_type_t class_opaque_type = class_type->GetClangType (true);
if (ClangASTContext::IsCXXClassType (class_opaque_type))
{
clang::CXXMethodDecl *cxx_method_decl;
@@ -2895,7 +3034,6 @@
case DW_TAG_array_type:
{
- //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag));
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
@@ -2958,7 +3096,7 @@
element_orders.push_back (1);
if (byte_stride == 0 && bit_stride == 0)
byte_stride = element_type->GetByteSize();
- void *array_element_type = element_type->GetOpaqueClangQualType();
+ clang_type_t array_element_type = element_type->GetClangType();
uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
uint64_t num_elements = 0;
std::vector<uint64_t>::const_reverse_iterator pos;
@@ -3006,8 +3144,8 @@
Type *pointee_type = ResolveTypeUID(type_die_offset);
Type *class_type = ResolveTypeUID(containing_type_die_offset);
- void *pointee_clang_type = pointee_type->GetOpaqueClangQualType();
- void *class_clang_type = class_type->GetOpaqueClangQualType();
+ clang_type_t pointee_clang_type = pointee_type->GetClangType();
+ clang_type_t class_clang_type = class_type->GetClangType();
clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type);
@@ -3071,13 +3209,20 @@
}
size_t
-SymbolFileDWARF::ParseTypes (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children)
+SymbolFileDWARF::ParseTypes
+(
+ const SymbolContext& sc,
+ DWARFCompileUnit* dwarf_cu,
+ const DWARFDebugInfoEntry *die,
+ bool parse_siblings,
+ bool parse_children
+)
{
size_t types_added = 0;
while (die != NULL)
{
bool type_is_new = false;
- if (ParseType(sc, dwarf_cu, die, type_is_new).get())
+ if (ParseType(sc, dwarf_cu, die, &type_is_new).get())
{
if (type_is_new)
++types_added;
@@ -3400,7 +3545,7 @@
Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset());
assert (block != NULL);
- variables = block->GetVariableList(false, true);
+ variables = block->GetVariableList(false, false);
if (variables.get() == NULL)
{
variables.reset(new VariableList());
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 3988113..e1542c0 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -94,6 +94,8 @@
virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc);
virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
+ virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_opaque_type);
+
virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die);
virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid);
@@ -214,7 +216,7 @@
bool parse_siblings,
bool parse_children);
size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children);
- lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new);
+ lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new);
lldb::VariableSP ParseVariableDIE(
const lldb_private::SymbolContext& sc,
@@ -233,10 +235,9 @@
size_t ParseChildMembers(
const lldb_private::SymbolContext& sc,
- lldb::TypeSP& type_sp,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *die,
- void *class_clang_type,
+ lldb::clang_type_t class_clang_type,
const lldb::LanguageType class_language,
std::vector<clang::CXXBaseSpecifier *>& base_classes,
std::vector<int>& member_accessibilities,
@@ -250,13 +251,12 @@
const DWARFDebugInfoEntry *parent_die,
bool skip_artificial,
lldb_private::TypeList* type_list,
- std::vector<void *>& function_args,
+ std::vector<lldb::clang_type_t>& function_args,
std::vector<clang::ParmVarDecl*>& function_param_decls);
size_t ParseChildEnumerators(
const lldb_private::SymbolContext& sc,
- lldb::TypeSP& type_sp,
- void *enumerator_qual_type,
+ lldb::clang_type_t enumerator_qual_type,
uint32_t enumerator_byte_size,
DWARFCompileUnit* dwarf_cu,
const DWARFDebugInfoEntry *enum_die);
@@ -281,10 +281,7 @@
lldb_private::SymbolContextList& sc_list);
lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu,
- const DWARFDebugInfoEntry* die,
- lldb::TypeSP& owning_type_sp,
- int32_t child_type,
- uint32_t idx);
+ const DWARFDebugInfoEntry* die);
uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, lldb_private::TypeList& types);
@@ -319,12 +316,13 @@
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
- typedef llvm::DenseMap<const DWARFDebugInfoEntry *, void *> DIEToClangType;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType;
+ typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE;
DIEToDeclContextMap m_die_to_decl_ctx;
DIEToTypePtr m_die_to_type;
DIEToVariableSP m_die_to_variable_sp;
- DIEToClangType m_die_to_clang_type;
-
+ DIEToClangType m_forward_decl_die_to_clang_type;
+ ClangTypeToDIE m_forward_decl_clang_type_to_die;
};
#endif // liblldb_SymbolFileDWARF_h_
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index d216ef5..7a85123 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -592,6 +592,12 @@
return NULL;
}
+lldb::clang_type_t
+SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type)
+{
+ // We have a struct/union/class/enum that needs to be fully resolved.
+ return NULL;
+}
uint32_t
SymbolFileDWARFDebugMap::ResolveSymbolContext (const Address& exe_so_addr, uint32_t resolve_scope, SymbolContext& sc)
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index adb0ec5..430000d 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -59,7 +59,8 @@
virtual size_t ParseTypes (const lldb_private::SymbolContext& sc);
virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc);
- virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid);
+ virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid);
+ virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type);
virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindGlobalVariables (const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 91e4cd4..e42553f 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -271,6 +271,11 @@
return NULL;
}
+lldb::clang_type_t
+SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type)
+{
+ return NULL;
+}
uint32_t
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index da43985..3d09cd4 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -74,6 +74,9 @@
virtual lldb_private::Type*
ResolveTypeUID(lldb::user_id_t type_uid);
+ virtual lldb::clang_type_t
+ ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type);
+
virtual uint32_t
ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index cf223b4..a0f483b 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -398,7 +398,7 @@
return false;
}
-void *
+clang_type_t
ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (Encoding encoding, uint32_t bit_size)
{
ASTContext *ast_context = getASTContext();
@@ -408,8 +408,8 @@
return GetBuiltinTypeForEncodingAndBitSize (ast_context, encoding, bit_size);
}
-void *
-ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (clang::ASTContext *ast_context, Encoding encoding, uint32_t bit_size)
+clang_type_t
+ClangASTContext::GetBuiltinTypeForEncodingAndBitSize (ASTContext *ast_context, Encoding encoding, uint32_t bit_size)
{
if (!ast_context)
return NULL;
@@ -468,7 +468,7 @@
return NULL;
}
-void *
+clang_type_t
ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
{
ASTContext *ast_context = getASTContext();
@@ -657,31 +657,31 @@
return NULL;
}
-void *
-ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context)
+clang_type_t
+ClangASTContext::GetBuiltInType_void(ASTContext *ast_context)
{
return ast_context->VoidTy.getAsOpaquePtr();
}
-void *
+clang_type_t
ClangASTContext::GetBuiltInType_objc_id()
{
return getASTContext()->getObjCIdType().getAsOpaquePtr();
}
-void *
+clang_type_t
ClangASTContext::GetBuiltInType_objc_Class()
{
return getASTContext()->getObjCClassType().getAsOpaquePtr();
}
-void *
+clang_type_t
ClangASTContext::GetBuiltInType_objc_selector()
{
return getASTContext()->getObjCSelType().getAsOpaquePtr();
}
-void *
+clang_type_t
ClangASTContext::GetCStringType (bool is_const)
{
QualType char_type(getASTContext()->CharTy);
@@ -692,14 +692,14 @@
return getASTContext()->getPointerType(char_type).getAsOpaquePtr();
}
-void *
+clang_type_t
ClangASTContext::GetVoidPtrType (bool is_const)
{
return GetVoidPtrType(getASTContext(), is_const);
}
-void *
-ClangASTContext::GetVoidPtrType (clang::ASTContext *ast_context, bool is_const)
+clang_type_t
+ClangASTContext::GetVoidPtrType (ASTContext *ast_context, bool is_const)
{
QualType void_ptr_type(ast_context->VoidPtrTy);
@@ -709,10 +709,10 @@
return void_ptr_type.getAsOpaquePtr();
}
-void *
-ClangASTContext::CopyType(clang::ASTContext *dest_context,
- clang::ASTContext *source_context,
- void *clang_type)
+clang_type_t
+ClangASTContext::CopyType (ASTContext *dest_context,
+ ASTContext *source_context,
+ clang_type_t clang_type)
{
Diagnostic diagnostics;
FileManager file_manager;
@@ -724,9 +724,9 @@
}
bool
-ClangASTContext::AreTypesSame(clang::ASTContext *ast_context,
- void *type1,
- void *type2)
+ClangASTContext::AreTypesSame(ASTContext *ast_context,
+ clang_type_t type1,
+ clang_type_t type2)
{
return ast_context->hasSameType(QualType::getFromOpaquePtr(type1),
QualType::getFromOpaquePtr(type2));
@@ -734,8 +734,8 @@
#pragma mark CVR modifiers
-void *
-ClangASTContext::AddConstModifier (void *clang_type)
+clang_type_t
+ClangASTContext::AddConstModifier (clang_type_t clang_type)
{
if (clang_type)
{
@@ -746,8 +746,8 @@
return NULL;
}
-void *
-ClangASTContext::AddRestrictModifier (void *clang_type)
+clang_type_t
+ClangASTContext::AddRestrictModifier (clang_type_t clang_type)
{
if (clang_type)
{
@@ -758,8 +758,8 @@
return NULL;
}
-void *
-ClangASTContext::AddVolatileModifier (void *clang_type)
+clang_type_t
+ClangASTContext::AddVolatileModifier (clang_type_t clang_type)
{
if (clang_type)
{
@@ -772,7 +772,7 @@
#pragma mark Structure, Unions, Classes
-void *
+clang_type_t
ClangASTContext::CreateRecordType (const char *name, int kind, DeclContext *decl_ctx, LanguageType language)
{
ASTContext *ast_context = getASTContext();
@@ -806,10 +806,10 @@
CXXMethodDecl *
ClangASTContext::AddMethodToCXXRecordType
(
- clang::ASTContext *ast_context,
- void *record_opaque_type,
+ ASTContext *ast_context,
+ clang_type_t record_opaque_type,
const char *name,
- void *method_opaque_type,
+ clang_type_t method_opaque_type,
lldb::AccessType access,
bool is_virtual,
bool is_static,
@@ -859,7 +859,7 @@
is_inline);
- clang::AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access);
+ AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access);
cxx_method_decl->setAccess (access_specifier);
cxx_method_decl->setVirtualAsWritten (is_virtual);
@@ -904,10 +904,10 @@
bool
ClangASTContext::AddFieldToRecordType
(
- clang::ASTContext *ast_context,
- void *record_clang_type,
+ ASTContext *ast_context,
+ clang_type_t record_clang_type,
const char *name,
- void *field_type,
+ clang_type_t field_type,
AccessType access,
uint32_t bitfield_bit_size
)
@@ -1069,7 +1069,7 @@
}
void
-ClangASTContext::SetDefaultAccessForRecordFields (void *clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities)
+ClangASTContext::SetDefaultAccessForRecordFields (clang_type_t clang_qual_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities)
{
if (clang_qual_type)
{
@@ -1102,7 +1102,7 @@
#pragma mark C++ Base Classes
CXXBaseSpecifier *
-ClangASTContext::CreateBaseClassSpecifier (void *base_class_type, AccessType access, bool is_virtual, bool base_of_class)
+ClangASTContext::CreateBaseClassSpecifier (clang_type_t base_class_type, AccessType access, bool is_virtual, bool base_of_class)
{
if (base_class_type)
return new CXXBaseSpecifier (SourceRange(),
@@ -1124,7 +1124,7 @@
}
bool
-ClangASTContext::SetBaseClassesForClassType (void *class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes)
+ClangASTContext::SetBaseClassesForClassType (clang_type_t class_clang_type, CXXBaseSpecifier const * const *base_classes, unsigned num_base_classes)
{
if (class_clang_type)
{
@@ -1188,7 +1188,7 @@
}
#pragma mark Objective C Classes
-void *
+clang_type_t
ClangASTContext::CreateObjCClass
(
const char *name,
@@ -1220,7 +1220,7 @@
}
bool
-ClangASTContext::SetObjCSuperClass (void *class_opaque_type, void *super_opaque_type)
+ClangASTContext::SetObjCSuperClass (clang_type_t class_opaque_type, clang_type_t super_opaque_type)
{
if (class_opaque_type && super_opaque_type)
{
@@ -1251,10 +1251,10 @@
bool
ClangASTContext::AddObjCClassIVar
(
- clang::ASTContext *ast_context,
- void *class_opaque_type,
+ ASTContext *ast_context,
+ clang_type_t class_opaque_type,
const char *name,
- void *ivar_opaque_type,
+ clang_type_t ivar_opaque_type,
AccessType access,
uint32_t bitfield_bit_size,
bool is_synthesized
@@ -1311,7 +1311,7 @@
bool
-ClangASTContext::ObjCTypeHasIVars (void *class_opaque_type, bool check_superclass)
+ClangASTContext::ObjCTypeHasIVars (clang_type_t class_opaque_type, bool check_superclass)
{
QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type));
@@ -1342,13 +1342,13 @@
return false;
}
-clang::ObjCMethodDecl *
+ObjCMethodDecl *
ClangASTContext::AddMethodToObjCObjectType
(
- clang::ASTContext *ast_context,
- void *class_opaque_type,
+ ASTContext *ast_context,
+ clang_type_t class_opaque_type,
const char *name, // the full symbol name as seen in the symbol table ("-[NString stringWithCString:]")
- void *method_opaque_type,
+ clang_type_t method_opaque_type,
lldb::AccessType access
)
{
@@ -1471,7 +1471,7 @@
#pragma mark Aggregate Types
bool
-ClangASTContext::IsAggregateType (void *clang_type)
+ClangASTContext::IsAggregateType (clang_type_t clang_type)
{
if (clang_type == NULL)
return false;
@@ -1505,7 +1505,7 @@
}
uint32_t
-ClangASTContext::GetNumChildren (void *clang_qual_type, bool omit_empty_base_classes)
+ClangASTContext::GetNumChildren (clang_type_t clang_qual_type, bool omit_empty_base_classes)
{
if (clang_qual_type == NULL)
return 0;
@@ -1642,11 +1642,11 @@
}
-void *
+clang_type_t
ClangASTContext::GetChildClangTypeAtIndex
(
const char *parent_name,
- void *parent_clang_type,
+ clang_type_t parent_clang_type,
uint32_t idx,
bool transparent_pointers,
bool omit_empty_base_classes,
@@ -1673,12 +1673,12 @@
return NULL;
}
-void *
+clang_type_t
ClangASTContext::GetChildClangTypeAtIndex
(
ASTContext *ast_context,
const char *parent_name,
- void *parent_clang_type,
+ clang_type_t parent_clang_type,
uint32_t idx,
bool transparent_pointers,
bool omit_empty_base_classes,
@@ -2186,7 +2186,7 @@
ClangASTContext::GetIndexOfChildMemberWithName
(
ASTContext *ast_context,
- void *clang_type,
+ clang_type_t clang_type,
const char *name,
bool omit_empty_base_classes,
std::vector<uint32_t>& child_indexes
@@ -2464,7 +2464,7 @@
ClangASTContext::GetIndexOfChildWithName
(
ASTContext *ast_context,
- void *clang_type,
+ clang_type_t clang_type,
const char *name,
bool omit_empty_base_classes
)
@@ -2668,7 +2668,7 @@
#pragma mark TagType
bool
-ClangASTContext::SetTagTypeKind (void *tag_clang_type, int kind)
+ClangASTContext::SetTagTypeKind (clang_type_t tag_clang_type, int kind)
{
if (tag_clang_type)
{
@@ -2695,7 +2695,7 @@
#pragma mark DeclContext Functions
DeclContext *
-ClangASTContext::GetDeclContextForType (void *clang_type)
+ClangASTContext::GetDeclContextForType (clang_type_t clang_type)
{
if (clang_type == NULL)
return NULL;
@@ -2756,7 +2756,7 @@
#pragma mark Function Types
FunctionDecl *
-ClangASTContext::CreateFunctionDeclaration (const char *name, void *function_clang_type, int storage, bool is_inline)
+ClangASTContext::CreateFunctionDeclaration (const char *name, clang_type_t function_clang_type, int storage, bool is_inline)
{
if (name)
{
@@ -2791,10 +2791,10 @@
return NULL;
}
-void *
-ClangASTContext::CreateFunctionType (clang::ASTContext *ast_context,
- void *result_type,
- void **args,
+clang_type_t
+ClangASTContext::CreateFunctionType (ASTContext *ast_context,
+ clang_type_t result_type,
+ clang_type_t *args,
unsigned num_args,
bool is_variadic,
unsigned type_quals)
@@ -2818,7 +2818,7 @@
}
ParmVarDecl *
-ClangASTContext::CreateParameterDeclaration (const char *name, void *param_type, int storage)
+ClangASTContext::CreateParameterDeclaration (const char *name, clang_type_t param_type, int storage)
{
ASTContext *ast_context = getASTContext();
assert (ast_context != NULL);
@@ -2843,8 +2843,8 @@
#pragma mark Array Types
-void *
-ClangASTContext::CreateArrayType (void *element_type, size_t element_count, uint32_t bit_stride)
+clang_type_t
+ClangASTContext::CreateArrayType (clang_type_t element_type, size_t element_count, uint32_t bit_stride)
{
if (element_type)
{
@@ -2863,7 +2863,7 @@
#pragma mark TagDecl
bool
-ClangASTContext::StartTagDeclarationDefinition (void *clang_type)
+ClangASTContext::StartTagDeclarationDefinition (clang_type_t clang_type)
{
if (clang_type)
{
@@ -2887,7 +2887,7 @@
}
bool
-ClangASTContext::CompleteTagDeclarationDefinition (void *clang_type)
+ClangASTContext::CompleteTagDeclarationDefinition (clang_type_t clang_type)
{
if (clang_type)
{
@@ -2913,8 +2913,8 @@
#pragma mark Enumeration Types
-void *
-ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type)
+clang_type_t
+ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, clang_type_t integer_qual_type)
{
// TODO: Do something intelligent with the Declaration object passed in
// like maybe filling in the SourceLocation with it...
@@ -2935,11 +2935,29 @@
return NULL;
}
+clang_type_t
+ClangASTContext::GetEnumerationIntegerType (clang_type_t enum_clang_type)
+{
+ QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type));
+
+ clang::Type *clang_type = enum_qual_type.getTypePtr();
+ if (clang_type)
+ {
+ const EnumType *enum_type = dyn_cast<EnumType>(clang_type);
+ if (enum_type)
+ {
+ EnumDecl *enum_decl = enum_type->getDecl();
+ if (enum_decl)
+ return enum_decl->getIntegerType().getAsOpaquePtr();
+ }
+ }
+ return NULL;
+}
bool
ClangASTContext::AddEnumerationValueToEnumerationType
(
- void *enum_clang_type,
- void *enumerator_clang_type,
+ clang_type_t enum_clang_type,
+ clang_type_t enumerator_clang_type,
const Declaration &decl,
const char *name,
int64_t enum_value,
@@ -2988,8 +3006,8 @@
#pragma mark Pointers & References
-void *
-ClangASTContext::CreatePointerType (void *clang_type)
+clang_type_t
+ClangASTContext::CreatePointerType (clang_type_t clang_type)
{
if (clang_type)
{
@@ -3009,24 +3027,24 @@
return NULL;
}
-void *
-ClangASTContext::CreateLValueReferenceType (void *clang_type)
+clang_type_t
+ClangASTContext::CreateLValueReferenceType (clang_type_t clang_type)
{
if (clang_type)
return getASTContext()->getLValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr();
return NULL;
}
-void *
-ClangASTContext::CreateRValueReferenceType (void *clang_type)
+clang_type_t
+ClangASTContext::CreateRValueReferenceType (clang_type_t clang_type)
{
if (clang_type)
return getASTContext()->getRValueReferenceType (QualType::getFromOpaquePtr(clang_type)).getAsOpaquePtr();
return NULL;
}
-void *
-ClangASTContext::CreateMemberPointerType (void *clang_pointee_type, void *clang_class_type)
+clang_type_t
+ClangASTContext::CreateMemberPointerType (clang_type_t clang_pointee_type, clang_type_t clang_class_type)
{
if (clang_pointee_type && clang_pointee_type)
return getASTContext()->getMemberPointerType(QualType::getFromOpaquePtr(clang_pointee_type),
@@ -3042,7 +3060,7 @@
}
bool
-ClangASTContext::IsPointerOrReferenceType (void *clang_type, void **target_type)
+ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t*target_type)
{
if (clang_type == NULL)
return false;
@@ -3084,7 +3102,7 @@
}
bool
-ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed)
+ClangASTContext::IsIntegerType (clang_type_t clang_type, bool &is_signed)
{
if (!clang_type)
return false;
@@ -3104,7 +3122,7 @@
}
bool
-ClangASTContext::IsPointerType (void *clang_type, void **target_type)
+ClangASTContext::IsPointerType (clang_type_t clang_type, clang_type_t*target_type)
{
if (clang_type)
{
@@ -3138,7 +3156,7 @@
}
bool
-ClangASTContext::IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex)
+ClangASTContext::IsFloatingPointType (clang_type_t clang_type, uint32_t &count, bool &is_complex)
{
if (clang_type)
{
@@ -3177,7 +3195,7 @@
}
bool
-ClangASTContext::IsCXXClassType (void *clang_type)
+ClangASTContext::IsCXXClassType (clang_type_t clang_type)
{
if (clang_type)
{
@@ -3189,7 +3207,7 @@
}
bool
-ClangASTContext::IsObjCClassType (void *clang_type)
+ClangASTContext::IsObjCClassType (clang_type_t clang_type)
{
if (clang_type)
{
@@ -3204,7 +3222,7 @@
bool
-ClangASTContext::IsCStringType (void *clang_type, uint32_t &length)
+ClangASTContext::IsCStringType (clang_type_t clang_type, uint32_t &length)
{
if (clang_type)
{
@@ -3268,7 +3286,7 @@
}
bool
-ClangASTContext::IsFunctionPointerType (void *clang_type)
+ClangASTContext::IsFunctionPointerType (clang_type_t clang_type)
{
if (clang_type)
{
@@ -3300,7 +3318,7 @@
bool
-ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *size)
+ClangASTContext::IsArrayType (clang_type_t clang_type, clang_type_t*member_type, uint64_t *size)
{
if (!clang_type)
return false;
@@ -3340,8 +3358,8 @@
#pragma mark Typedefs
-void *
-ClangASTContext::CreateTypedefType (const char *name, void *clang_type, DeclContext *decl_ctx)
+clang_type_t
+ClangASTContext::CreateTypedefType (const char *name, clang_type_t clang_type, DeclContext *decl_ctx)
{
if (clang_type)
{
@@ -3366,16 +3384,16 @@
std::string
-ClangASTContext::GetTypeName (void *opaque_qual_type)
+ClangASTContext::GetTypeName (clang_type_t opaque_qual_type)
{
std::string return_name;
- clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_qual_type));
+ QualType qual_type(QualType::getFromOpaquePtr(opaque_qual_type));
- const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
+ const TypedefType *typedef_type = qual_type->getAs<TypedefType>();
if (typedef_type)
{
- const clang::TypedefDecl *typedef_decl = typedef_type->getDecl();
+ const TypedefDecl *typedef_decl = typedef_type->getDecl();
return_name = typedef_decl->getQualifiedNameAsString();
}
else
@@ -3393,7 +3411,7 @@
// so we can support remote targets. The code below also requires a patch to
// llvm::APInt.
//bool
-//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, void *clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
+//ClangASTContext::ConvertFloatValueToString (ASTContext *ast_context, clang_type_t clang_type, const uint8_t* bytes, size_t byte_size, int apint_byte_order, std::string &float_str)
//{
// uint32_t count = 0;
// bool is_complex = false;
@@ -3428,7 +3446,7 @@
//}
size_t
-ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, void *clang_type, const char *s, uint8_t *dst, size_t dst_size)
+ClangASTContext::ConvertStringToFloatValue (ASTContext *ast_context, clang_type_t clang_type, const char *s, uint8_t *dst, size_t dst_size)
{
if (clang_type)
{
@@ -3467,7 +3485,7 @@
}
unsigned
-ClangASTContext::GetTypeQualifiers(void *clang_type)
+ClangASTContext::GetTypeQualifiers(clang_type_t clang_type)
{
assert (clang_type);
diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp
index 64e1c71..cccec2a 100644
--- a/source/Symbol/ClangASTType.cpp
+++ b/source/Symbol/ClangASTType.cpp
@@ -804,6 +804,29 @@
return 0;
}
+
+bool
+ClangASTType::IsDefined()
+{
+ return ClangASTType::IsDefined (m_type);
+}
+
+
+bool
+ClangASTType::IsDefined (void *opaque_clang_qual_type)
+{
+ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+ clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type.getTypePtr());
+ if (tag_type)
+ {
+ clang::TagDecl *tag_decl = tag_type->getDecl();
+ if (tag_decl)
+ return tag_decl->getDefinition() != NULL;
+ return false;
+ }
+ return true;
+}
+
void
ClangASTType::DumpTypeDescription (Stream *s)
{
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 3c108d7..41a708c 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -402,7 +402,7 @@
Type
Function::GetReturnType ()
{
- clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType()));
+ clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
assert (clang_type->isFunctionType());
clang::FunctionType *function_type = dyn_cast<clang::FunctionType> (clang_type);
clang::QualType fun_return_qualtype = function_type->getResultType();
@@ -421,7 +421,7 @@
int
Function::GetArgumentCount ()
{
- clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType()));
+ clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
assert (clang_type->isFunctionType());
if (!clang_type->isFunctionProtoType())
return -1;
@@ -436,7 +436,7 @@
const Type
Function::GetArgumentTypeAtIndex (size_t idx)
{
- clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetOpaqueClangQualType()));
+ clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
assert (clang_type->isFunctionType());
if (!clang_type->isFunctionProtoType())
return Type();
@@ -465,7 +465,7 @@
const char *
Function::GetArgumentNameAtIndex (size_t idx)
{
- clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetOpaqueClangQualType())->getTypePtr();
+ clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr();
assert (clang_type->isFunctionType());
if (!clang_type->isFunctionProtoType())
return NULL;
@@ -475,7 +475,7 @@
bool
Function::IsVariadic ()
{
- const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetOpaqueClangQualType())->getTypePtr();
+ const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr();
assert (clang_type->isFunctionType());
if (!clang_type->isFunctionProtoType())
return false;
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 4a5e4e1..a4f0410 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -26,6 +26,8 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+using namespace lldb;
+
lldb_private::Type::Type
(
lldb::user_id_t uid,
@@ -36,7 +38,7 @@
lldb::user_id_t encoding_uid,
EncodingUIDType encoding_uid_type,
const Declaration& decl,
- void *clang_type
+ clang_type_t clang_type
) :
UserID (uid),
m_name (name),
@@ -176,7 +178,7 @@
{
if (!(m_name))
{
- if (ResolveClangType())
+ if (ResolveClangType(true))
{
std::string type_name = ClangASTContext::GetTypeName (m_clang_qual_type);
if (!type_name.empty())
@@ -206,7 +208,7 @@
lldb::Format format
)
{
- if (ResolveClangType())
+ if (ResolveClangType(true))
{
if (show_types)
{
@@ -254,7 +256,7 @@
}
if (m_byte_size == 0)
{
- uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetOpaqueClangQualType());
+ uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType());
m_byte_size = (bit_width + 7 ) / 8;
}
break;
@@ -396,7 +398,7 @@
}
bool
-lldb_private::Type::ResolveClangType()
+lldb_private::Type::ResolveClangType (bool forward_decl_is_ok)
{
if (m_clang_qual_type == NULL)
{
@@ -410,38 +412,38 @@
switch (m_encoding_uid_type)
{
case eIsTypeWithUID:
- m_clang_qual_type = encoding_type->GetOpaqueClangQualType();
+ m_clang_qual_type = encoding_type->GetClangType();
break;
case eIsConstTypeWithUID:
- m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetOpaqueClangQualType());
+ m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(forward_decl_is_ok));
break;
case eIsRestrictTypeWithUID:
- m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetOpaqueClangQualType());
+ m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(forward_decl_is_ok));
break;
case eIsVolatileTypeWithUID:
- m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetOpaqueClangQualType());
+ m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(forward_decl_is_ok));
break;
case eTypedefToTypeWithUID:
- m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type);
+ m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, forward_decl_is_ok);
// Clear the name so it can get fully qualified in case the
// typedef is in a namespace.
m_name.Clear();
break;
case ePointerToTypeWithUID:
- m_clang_qual_type = type_list->CreateClangPointerType (encoding_type);
+ m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, forward_decl_is_ok);
break;
case eLValueReferenceToTypeWithUID:
- m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type);
+ m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, forward_decl_is_ok);
break;
case eRValueReferenceToTypeWithUID:
- m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type);
+ m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, forward_decl_is_ok);
break;
default:
@@ -449,11 +451,14 @@
break;
}
}
+ // Return here since we won't need to check if this is a forward
+ // declaration below since we already obeyed this above.
+ return m_clang_qual_type != NULL;
}
else
{
// We have no encoding type, return void?
- void *void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
+ clang_type_t void_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
switch (m_encoding_uid_type)
{
case eIsTypeWithUID:
@@ -494,10 +499,18 @@
}
}
}
+
+ // Check if we have a forward reference to a class/struct/union/enum?
+ if (!forward_decl_is_ok && !ClangASTType::IsDefined (m_clang_qual_type))
+ {
+ // We have a forward declaration, we need to resolve it to a complete
+ // definition.
+ m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type);
+ }
return m_clang_qual_type != NULL;
}
-void *
+clang_type_t
lldb_private::Type::GetChildClangTypeAtIndex
(
const char *parent_name,
@@ -515,7 +528,7 @@
return NULL;
std::string name_str;
- void *child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (
+ clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (
parent_name,
m_clang_qual_type,
idx,
@@ -539,10 +552,10 @@
-void *
-lldb_private::Type::GetOpaqueClangQualType ()
+clang_type_t
+lldb_private::Type::GetClangType (bool forward_decl_is_ok)
{
- ResolveClangType();
+ ResolveClangType(forward_decl_is_ok);
return m_clang_qual_type;
}
diff --git a/source/Symbol/TypeList.cpp b/source/Symbol/TypeList.cpp
index 4595a9f..f4bcfdf 100644
--- a/source/Symbol/TypeList.cpp
+++ b/source/Symbol/TypeList.cpp
@@ -208,31 +208,31 @@
}
void *
-TypeList::CreateClangPointerType (Type *type)
+TypeList::CreateClangPointerType (Type *type, bool forward_decl_is_ok)
{
assert(type);
- return m_ast.CreatePointerType(type->GetOpaqueClangQualType());
+ return m_ast.CreatePointerType(type->GetClangType(forward_decl_is_ok));
}
void *
-TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type)
+TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok)
{
assert(typedef_type && base_type);
- return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetOpaqueClangQualType(), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
+ return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetClangType(forward_decl_is_ok), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
}
void *
-TypeList::CreateClangLValueReferenceType (Type *type)
+TypeList::CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok)
{
assert(type);
- return m_ast.CreateLValueReferenceType(type->GetOpaqueClangQualType());
+ return m_ast.CreateLValueReferenceType(type->GetClangType(forward_decl_is_ok));
}
void *
-TypeList::CreateClangRValueReferenceType (Type *type)
+TypeList::CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok)
{
assert(type);
- return m_ast.CreateRValueReferenceType (type->GetOpaqueClangQualType());
+ return m_ast.CreateRValueReferenceType (type->GetClangType(forward_decl_is_ok));
}