Modified the lldb_private::Type clang type resolving code to handle three
cases when getting the clang type:
- need only a forward declaration
- need a clang type that can be used for layout (members and args/return types)
- need a full clang type
This allows us to partially parse the clang types and be as lazy as possible.
The first case is when we just need to declare a type and we will complete it
later. The forward declaration happens only for class/union/structs and enums.
The layout type allows us to resolve the full clang type _except_ if we have
any modifiers on a pointer or reference (both R and L value). In this case
when we are adding members or function args or return types, we only need to
know how the type will be laid out and we can defer completing the pointee
type until we later need it. The last type means we need a full definition for
the clang type.
Did some renaming of some enumerations to get rid of the old "DC" prefix (which
stands for DebugCore which is no longer around).
Modified the clang namespace support to be almost ready to be fed to the
expression parser. I made a new ClangNamespaceDecl class that can carry around
the AST and the namespace decl so we can copy it into the expression AST. I
modified the symbol vendor and symbol file plug-ins to use this new class.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118976 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp
index fd57df6..896a058 100644
--- a/source/Commands/CommandObjectArgs.cpp
+++ b/source/Commands/CommandObjectArgs.cpp
@@ -249,7 +249,7 @@
return false;
}
- value.SetContext (Value::eContextTypeOpaqueClangQualType, type);
+ value.SetContext (Value::eContextTypeClangType, type);
value_list.PushValue(value);
}
diff --git a/source/Commands/CommandObjectCall.cpp b/source/Commands/CommandObjectCall.cpp
index 2674668..9a1a797 100644
--- a/source/Commands/CommandObjectCall.cpp
+++ b/source/Commands/CommandObjectCall.cpp
@@ -257,7 +257,7 @@
void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true);
- val.SetContext (Value::eContextTypeOpaqueClangQualType, cstr_type);
+ val.SetContext (Value::eContextTypeClangType, cstr_type);
value_list.PushValue(val);
success = true;
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index 76f1097..920c467 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -287,7 +287,7 @@
if (m_context_type == eContextTypeValue)
return ((Value*)m_context)->GetRegisterInfo();
- if (m_context_type == eContextTypeDCRegisterInfo)
+ if (m_context_type == eContextTypeRegisterInfo)
return static_cast<RegisterInfo *> (m_context);
return NULL;
}
@@ -298,7 +298,7 @@
if (m_context_type == eContextTypeValue)
return ((Value*)m_context)->GetType();
- if (m_context_type == eContextTypeDCType)
+ if (m_context_type == eContextTypeLLDBType)
return static_cast<Type *> (m_context);
return NULL;
}
@@ -336,12 +336,12 @@
{
default:
case eContextTypeInvalid:
- case eContextTypeOpaqueClangQualType: // clang::Type *
- case eContextTypeDCRegisterInfo: // RegisterInfo *
- case eContextTypeDCType: // Type *
+ case eContextTypeClangType: // clang::Type *
+ case eContextTypeRegisterInfo: // RegisterInfo *
+ case eContextTypeLLDBType: // Type *
break;
- case eContextTypeDCVariable: // Variable *
+ case eContextTypeVariable: // Variable *
ResolveValue(exe_ctx, ast_context);
return true;
}
@@ -365,7 +365,7 @@
error_ptr->SetErrorString ("Invalid context type, there is no way to know how much memory to read.");
break;
- case eContextTypeOpaqueClangQualType:
+ case eContextTypeClangType:
if (ast_context == NULL)
{
if (error_ptr)
@@ -378,7 +378,7 @@
}
break;
- case eContextTypeDCRegisterInfo: // RegisterInfo *
+ case eContextTypeRegisterInfo: // RegisterInfo *
if (GetRegisterInfo())
byte_size = GetRegisterInfo()->byte_size;
else if (error_ptr)
@@ -386,14 +386,14 @@
break;
- case eContextTypeDCType: // Type *
+ case eContextTypeLLDBType: // Type *
if (GetType())
byte_size = GetType()->GetByteSize();
else if (error_ptr)
error_ptr->SetErrorString ("Can't determine byte size with NULL Type *.");
break;
- case eContextTypeDCVariable: // Variable *
+ case eContextTypeVariable: // Variable *
if (GetVariable())
byte_size = GetVariable()->GetType()->GetByteSize();
else if (error_ptr)
@@ -428,18 +428,18 @@
case eContextTypeInvalid:
break;
- case eContextTypeOpaqueClangQualType:
+ case eContextTypeClangType:
return m_context;
- case eContextTypeDCRegisterInfo:
+ case eContextTypeRegisterInfo:
break; // TODO: Eventually convert into a clang type?
- case eContextTypeDCType:
+ case eContextTypeLLDBType:
if (GetType())
return GetType()->GetClangType();
break;
- case eContextTypeDCVariable:
+ case eContextTypeVariable:
if (GetVariable())
return GetVariable()->GetType()->GetClangType();
break;
@@ -460,20 +460,20 @@
case eContextTypeInvalid:
break;
- case eContextTypeOpaqueClangQualType:
+ case eContextTypeClangType:
return ClangASTType::GetFormat (m_context);
- case eContextTypeDCRegisterInfo:
+ case eContextTypeRegisterInfo:
if (GetRegisterInfo())
return GetRegisterInfo()->format;
break;
- case eContextTypeDCType:
+ case eContextTypeLLDBType:
if (GetType())
return GetType()->GetFormat();
break;
- case eContextTypeDCVariable:
+ case eContextTypeVariable:
if (GetVariable())
return GetVariable()->GetType()->GetFormat();
break;
@@ -669,7 +669,7 @@
}
}
- if (m_context_type == eContextTypeOpaqueClangQualType)
+ if (m_context_type == eContextTypeClangType)
{
void *opaque_clang_qual_type = GetClangType();
switch (m_value_type)
@@ -731,7 +731,7 @@
if (m_context_type == eContextTypeValue)
return ((Value*)m_context)->GetVariable();
- if (m_context_type == eContextTypeDCVariable)
+ if (m_context_type == eContextTypeVariable)
return static_cast<Variable *> (m_context);
return NULL;
}
@@ -757,10 +757,10 @@
switch (context_type)
{
case eContextTypeInvalid: return "invalid";
- case eContextTypeOpaqueClangQualType: return "clang::Type *";
- case eContextTypeDCRegisterInfo: return "RegisterInfo *";
- case eContextTypeDCType: return "Type *";
- case eContextTypeDCVariable: return "Variable *";
+ case eContextTypeClangType: return "clang::Type *";
+ case eContextTypeRegisterInfo: return "RegisterInfo *";
+ case eContextTypeLLDBType: return "Type *";
+ case eContextTypeVariable: return "Variable *";
case eContextTypeValue: return "Value"; // TODO: Sean, more description here?
};
return "???";
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index a3da90d..64c646b 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -179,7 +179,7 @@
break;
case Value::eValueTypeScalar:
- if (m_value.GetContextType() == Value::eContextTypeDCRegisterInfo)
+ if (m_value.GetContextType() == Value::eContextTypeRegisterInfo)
{
RegisterInfo *reg_info = m_value.GetRegisterInfo();
if (reg_info)
@@ -611,9 +611,9 @@
switch (context_type)
{
- case Value::eContextTypeOpaqueClangQualType:
- case Value::eContextTypeDCType:
- case Value::eContextTypeDCVariable:
+ case Value::eContextTypeClangType:
+ case Value::eContextTypeLLDBType:
+ case Value::eContextTypeVariable:
{
clang_type_t clang_type = GetClangType ();
if (clang_type)
@@ -638,7 +638,7 @@
}
break;
- case Value::eContextTypeDCRegisterInfo:
+ case Value::eContextTypeRegisterInfo:
{
const RegisterInfo *reg_info = m_value.GetRegisterInfo();
if (reg_info)
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index ec93584..2e19372 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -135,7 +135,7 @@
{
if (parent->UpdateValueIfNeeded(exe_scope))
{
- m_value.SetContext(Value::eContextTypeOpaqueClangQualType, m_clang_type);
+ m_value.SetContext(Value::eContextTypeClangType, m_clang_type);
// Copy the parent scalar value and the scalar value type
m_value.GetScalar() = parent->GetValue().GetScalar();
diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp
index 93e2d3e..ef7c7b9 100644
--- a/source/Core/ValueObjectConstResult.cpp
+++ b/source/Core/ValueObjectConstResult.cpp
@@ -44,7 +44,7 @@
m_data.SetData(data_sp);
m_value.GetScalar() = (uintptr_t)data_sp->GetBytes();
m_value.SetValueType(Value::eValueTypeHostAddress);
- m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type);
+ m_value.SetContext(Value::eContextTypeClangType, clang_type);
m_name = name;
SetIsConstant ();
SetValueIsValid(true);
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 7f3603f..dabf838 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/source/Core/ValueObjectRegister.cpp
@@ -319,7 +319,7 @@
{
if (m_reg_ctx->ReadRegisterBytes (m_reg_num, m_data))
{
- m_value.SetContext(Value::eContextTypeDCRegisterInfo, (void *)m_reg_info);
+ m_value.SetContext(Value::eContextTypeRegisterInfo, (void *)m_reg_info);
m_value.SetValueType(Value::eValueTypeHostAddress);
m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
SetValueIsValid (true);
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index 104aa1f..4f8bfe2 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -120,7 +120,7 @@
Value old_value(m_value);
if (expr.Evaluate (&exe_ctx, GetClangAST(), loclist_base_load_addr, NULL, m_value, &m_error))
{
- m_value.SetContext(Value::eContextTypeDCVariable, variable);
+ m_value.SetContext(Value::eContextTypeVariable, variable);
Value::ValueType value_type = m_value.GetValueType();
@@ -184,7 +184,7 @@
// Copy the Value and set the context to use our Variable
// so it can extract read its value into m_data appropriately
Value value(m_value);
- value.SetContext(Value::eContextTypeDCVariable, variable);
+ value.SetContext(Value::eContextTypeVariable, variable);
m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0);
}
break;
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index aa7d458..92b1ebb 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -23,6 +23,7 @@
#include "lldb/Expression/ClangASTSource.h"
#include "lldb/Expression/ClangPersistentVariables.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -760,7 +761,7 @@
break;
case Value::eValueTypeScalar:
{
- if (location_value->GetContextType() != Value::eContextTypeDCRegisterInfo)
+ if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
{
StreamString ss;
@@ -1019,6 +1020,18 @@
else if (non_extern_symbol)
AddOneFunction(context, NULL, non_extern_symbol);
}
+
+ ClangNamespaceDecl namespace_decl (m_sym_ctx.FindNamespace(name));
+ if (namespace_decl)
+ {
+// clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl);
+// if (clang_namespace_decl)
+// {
+// // TODO: is this how we get the decl lookups to be called for
+// // this namespace??
+// clang_namespace_decl->setHasExternalLexicalStorage();
+// }
+ }
}
}
else
@@ -1179,7 +1192,7 @@
type_to_use = var_opaque_type;
if (var_location.get()->GetContextType() == Value::eContextTypeInvalid)
- var_location.get()->SetContext(Value::eContextTypeOpaqueClangQualType, type_to_use);
+ var_location.get()->SetContext(Value::eContextTypeClangType, type_to_use);
if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress)
{
@@ -1279,6 +1292,19 @@
}
}
+clang::NamespaceDecl *
+ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, const ClangNamespaceDecl &namespace_decl)
+{
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+
+ clang::Decl *copied_decl = ClangASTContext::CopyDecl (context.GetASTContext(),
+ namespace_decl.GetASTContext(),
+ namespace_decl.GetNamespaceDecl());
+
+ return dyn_cast<clang::NamespaceDecl>(copied_decl);
+}
+
void
ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Function* fun,
diff --git a/source/Expression/ClangExpressionVariable.cpp b/source/Expression/ClangExpressionVariable.cpp
index 370406e..d1ae1d5 100644
--- a/source/Expression/ClangExpressionVariable.cpp
+++ b/source/Expression/ClangExpressionVariable.cpp
@@ -83,7 +83,7 @@
if (m_data_sp.get() == NULL)
return false;
- value.SetContext(Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType());
+ value.SetContext(Value::eContextTypeClangType, m_user_type.GetOpaqueQualType());
value.SetValueType(Value::eValueTypeHostAddress);
value.GetScalar() = (uintptr_t)m_data_sp->GetBytes();
clang::ASTContext *ast_context = m_user_type.GetASTContext();
diff --git a/source/Expression/ClangFunction.cpp b/source/Expression/ClangFunction.cpp
index bc4fb73..40cddf3 100644
--- a/source/Expression/ClangFunction.cpp
+++ b/source/Expression/ClangFunction.cpp
@@ -327,7 +327,7 @@
// Special case: if it's a pointer, don't do anything (the ABI supports passing cstrings)
if (arg_value->GetValueType() == Value::eValueTypeHostAddress &&
- arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType &&
+ arg_value->GetContextType() == Value::eContextTypeClangType &&
ClangASTContext::IsPointerType(arg_value->GetClangType()))
continue;
@@ -421,7 +421,7 @@
uint32_t offset = 0;
uint64_t return_integer = data.GetMaxU64(&offset, m_return_size);
- ret_value.SetContext (Value::eContextTypeOpaqueClangQualType, m_function_return_qual_type);
+ ret_value.SetContext (Value::eContextTypeClangType, m_function_return_qual_type);
ret_value.SetValueType(Value::eValueTypeScalar);
ret_value.GetScalar() = return_integer;
return true;
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index 9c65e81..30381b0 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -658,7 +658,7 @@
else
{
value.SetValueType (Value::eValueTypeScalar);
- value.SetContext (Value::eContextTypeDCRegisterInfo, const_cast<RegisterInfo *>(reg_context->GetRegisterInfoAtIndex(native_reg)));
+ value.SetContext (Value::eContextTypeRegisterInfo, const_cast<RegisterInfo *>(reg_context->GetRegisterInfoAtIndex(native_reg)));
if (reg_context->ReadRegisterValue (native_reg, value.GetScalar()))
return true;
@@ -2121,7 +2121,7 @@
return false;
}
- if (array_val.GetContextType() != Value::eContextTypeOpaqueClangQualType)
+ if (array_val.GetContextType() != Value::eContextTypeClangType)
{
if (error_ptr)
error_ptr->SetErrorString("Arrays without Clang types are unhandled at this time.");
@@ -2169,7 +2169,7 @@
Value member;
- member.SetContext(Value::eContextTypeOpaqueClangQualType, member_type);
+ member.SetContext(Value::eContextTypeClangType, member_type);
member.SetValueType(array_val.GetValueType());
addr_t array_base = (addr_t)array_val.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
@@ -2212,7 +2212,7 @@
StreamString new_value(Stream::eBinary, 4, eByteOrderHost);
switch (context_type)
{
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
void *clang_type = stack.back().GetClangType();
@@ -2427,7 +2427,7 @@
tmp = stack.back();
stack.pop_back();
- if (tmp.GetContextType() != Value::eContextTypeOpaqueClangQualType)
+ if (tmp.GetContextType() != Value::eContextTypeClangType)
{
if (error_ptr)
error_ptr->SetErrorString("Item at top of expression stack must have a Clang type");
@@ -2450,7 +2450,7 @@
tmp.ResolveValue(exe_ctx, ast_context);
tmp.SetValueType(value_type);
- tmp.SetContext(Value::eContextTypeOpaqueClangQualType, target_type);
+ tmp.SetContext(Value::eContextTypeClangType, target_type);
stack.push_back(tmp);
}
@@ -2483,7 +2483,7 @@
Value *proxy = expr_local_variable->CreateProxy();
stack.push_back(*proxy);
delete proxy;
- //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetClangType());
+ //stack.back().SetContext (Value::eContextTypeClangType, expr_local_variable->GetClangType());
*/
}
break;
@@ -2548,7 +2548,7 @@
else
{
void *clang_type = (void *)opcodes.GetMaxU64(&offset, sizeof(void*));
- stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, clang_type);
+ stack.back().SetContext (Value::eContextTypeClangType, clang_type);
}
break;
//----------------------------------------------------------------------
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 21adec8..e5a5db7 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -234,7 +234,7 @@
{
default:
return false;
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
void *val_type = val->GetClangType();
uint32_t cstr_length;
@@ -433,7 +433,7 @@
{
default:
return false;
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
void *value_type = value->GetClangType();
bool is_signed;
@@ -472,7 +472,7 @@
{
default:
return false;
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
// Extract the Clang AST context from the PC so that we can figure out type
// sizes
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 e447df5..f4045cc 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -304,7 +304,7 @@
{
default:
return false;
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
void *value_type = value->GetClangType();
bool is_signed;
@@ -347,7 +347,7 @@
{
default:
return false;
- case Value::eContextTypeOpaqueClangQualType:
+ case Value::eContextTypeClangType:
{
void *value_type = value.GetClangType();
bool is_signed;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 65a363d..6e4fdb7 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -97,7 +97,7 @@
void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id();
if (opaque_type_ptr == NULL)
opaque_type_ptr = ast_context->GetVoidPtrType(false);
- value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr);
+ value.SetContext(Value::eContextTypeClangType, opaque_type_ptr);
}
ValueList arg_value_list;
@@ -109,7 +109,7 @@
void *return_qualtype = ast_context->GetCStringType(true);
Value ret;
- ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype);
+ ret.SetContext(Value::eContextTypeClangType, return_qualtype);
// Now we're ready to call the function:
ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list);
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 00d27d8..d768619 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -74,15 +74,15 @@
}
uint32_t offset_ptr = 0;
- uint16_t header_size = data.GetU16(&offset_ptr);
- uint16_t descriptor_size = data.GetU16(&offset_ptr);
- size_t num_descriptors = data.GetU32(&offset_ptr);
+ const uint16_t header_size = data.GetU16(&offset_ptr);
+ const uint16_t descriptor_size = data.GetU16(&offset_ptr);
+ const size_t num_descriptors = data.GetU32(&offset_ptr);
m_next_region = data.GetPointer(&offset_ptr);
// If the header size is 0, that means we've come in too early before this data is set up.
// Set ourselves as not valid, and continue.
- if (header_size == 0)
+ if (header_size == 0 || num_descriptors == 0)
{
m_valid = false;
return;
@@ -100,8 +100,8 @@
// to compute it over and over.
// Ingest the whole descriptor array:
- lldb::addr_t desc_ptr = m_header_addr + header_size;
- size_t desc_array_size = num_descriptors * descriptor_size;
+ const lldb::addr_t desc_ptr = m_header_addr + header_size;
+ const size_t desc_array_size = num_descriptors * descriptor_size;
DataBufferSP data_sp(new DataBufferHeap (desc_array_size, '\0'));
uint8_t* dst = (uint8_t*)data_sp->GetBytes();
@@ -291,7 +291,7 @@
Value input_value;
void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false);
input_value.SetValueType (Value::eValueTypeScalar);
- input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type);
+ input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
argument_values.PushValue(input_value);
bool success = abi->GetArgumentValues (*(context->exe_ctx.thread), argument_values);
@@ -515,7 +515,7 @@
Value input_value;
void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false);
input_value.SetValueType (Value::eValueTypeScalar);
- input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type);
+ input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type);
int obj_index;
int sel_index;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5deeb90..f3abd9e 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1158,7 +1158,7 @@
accessibility = default_accessibility;
member_accessibilities.push_back(accessibility);
- GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size);
+ GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangLayoutType(), accessibility, bit_size);
}
}
}
@@ -1226,16 +1226,16 @@
}
}
- Type *base_class_dctype = ResolveTypeUID(encoding_uid);
- assert(base_class_dctype);
+ Type *base_class_type = ResolveTypeUID(encoding_uid);
+ assert(base_class_type);
if (class_language == eLanguageTypeObjC)
{
- GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType());
+ GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_type->GetClangType());
}
else
{
- base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class));
+ base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), accessibility, is_virtual, is_base_of_class));
assert(base_classes.back());
}
}
@@ -2100,36 +2100,42 @@
}
-clang::NamespaceDecl *
+ClangNamespaceDecl
SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
const ConstString &name)
{
+ ClangNamespaceDecl namespace_decl;
DWARFDebugInfo* info = DebugInfo();
- if (info == NULL)
- return 0;
-
- // Index if we already haven't to make sure the compile units
- // get indexed and make their global DIE index list
- if (!m_indexed)
- Index ();
-
- DWARFCompileUnit* curr_cu = NULL;
- DWARFCompileUnit* prev_cu = NULL;
- const DWARFDebugInfoEntry* die = NULL;
- std::vector<NameToDIE::Info> die_info_array;
- const size_t num_matches = m_namespace_index.Find (name, die_info_array);
- for (size_t i=0; i<num_matches; ++i, prev_cu = curr_cu)
+ if (info)
{
- curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
-
- if (curr_cu != prev_cu)
- curr_cu->ExtractDIEsIfNeeded (false);
+ // Index if we already haven't to make sure the compile units
+ // get indexed and make their global DIE index list
+ if (!m_indexed)
+ Index ();
- die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+ DWARFCompileUnit* curr_cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = m_namespace_index.Find (name, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = curr_cu)
+ {
+ curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (curr_cu != prev_cu)
+ curr_cu->ExtractDIEsIfNeeded (false);
- return ResolveNamespaceDIE (curr_cu, die);
+ die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+
+ clang::NamespaceDecl *clang_namespace_decl = ResolveNamespaceDIE (curr_cu, die);
+ if (clang_namespace_decl)
+ {
+ namespace_decl.SetASTContext (GetClangASTContext().getASTContext());
+ namespace_decl.SetNamespaceDecl (clang_namespace_decl);
+ }
+ }
}
- return NULL;
+ return namespace_decl;
}
uint32_t
@@ -2700,6 +2706,10 @@
DWARFDebugInfoEntry::Attributes attributes;
const char *type_name_cstr = NULL;
ConstString type_name_const_str;
+ Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
+ size_t byte_size = 0;
+ Declaration decl;
+
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
clang_type_t clang_type = NULL;
@@ -2719,9 +2729,7 @@
m_die_to_type[die] = DIE_IS_BEING_PARSED;
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
- Declaration decl;
uint32_t encoding = 0;
- size_t byte_size = 0;
lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
if (num_attributes > 0)
@@ -2758,47 +2766,21 @@
switch (tag)
{
default:
+ break;
+
case DW_TAG_base_type:
+ resolve_state = Type::eResolveStateFull;
clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr,
encoding,
byte_size * 8);
break;
- case DW_TAG_pointer_type:
- // The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetClangType()
- encoding_data_type = Type::eEncodingIsPointerUID;
- break;
-
- case DW_TAG_reference_type:
- // The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetClangType()
- encoding_data_type = Type::eEncodingIsLValueReferenceUID;
- break;
-
- case DW_TAG_typedef:
- // The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetClangType()
- encoding_data_type = Type::eEncodingIsTypedefUID;
- break;
-
- case DW_TAG_const_type:
- // The encoding_uid will be embedded into the
- // Type object and will be looked up when the Type::GetClangType()
- encoding_data_type = Type::eEncodingIsConstUID; //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::GetClangType()
- encoding_data_type = Type::eEncodingIsRestrictUID; //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::GetClangType()
- encoding_data_type = Type::eEncodingIsVolatileUID; //ClangASTContext::AddVolatileModifier (clang_type);
- break;
+ case DW_TAG_pointer_type: encoding_data_type = Type::eEncodingIsPointerUID; break;
+ case DW_TAG_reference_type: encoding_data_type = Type::eEncodingIsLValueReferenceUID; break;
+ case DW_TAG_typedef: encoding_data_type = Type::eEncodingIsTypedefUID; break;
+ case DW_TAG_const_type: encoding_data_type = Type::eEncodingIsConstUID; break;
+ case DW_TAG_restrict_type: encoding_data_type = Type::eEncodingIsRestrictUID; break;
+ case DW_TAG_volatile_type: encoding_data_type = Type::eEncodingIsVolatileUID; break;
}
if (type_name_cstr != NULL && sc.comp_unit != NULL &&
@@ -2811,14 +2793,18 @@
if (type_name_const_str == g_objc_type_name_id)
{
clang_type = ast.GetBuiltInType_objc_id();
+ resolve_state = Type::eResolveStateFull;
+
}
else if (type_name_const_str == g_objc_type_name_Class)
{
clang_type = ast.GetBuiltInType_objc_Class();
+ resolve_state = Type::eResolveStateFull;
}
else if (type_name_const_str == g_objc_type_name_selector)
{
clang_type = ast.GetBuiltInType_objc_selector();
+ resolve_state = Type::eResolveStateFull;
}
}
@@ -2831,7 +2817,7 @@
encoding_data_type,
&decl,
clang_type,
- clang_type == NULL));
+ resolve_state));
m_die_to_type[die] = type_sp.get();
@@ -2853,10 +2839,8 @@
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
- size_t byte_size = 0;
LanguageType class_language = eLanguageTypeUnknown;
//bool struct_is_class = false;
- Declaration decl;
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
if (num_attributes > 0)
{
@@ -2974,7 +2958,6 @@
// parameters in any class methods need it for the clang
// types for function prototypes.
m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
- const bool is_forward_decl = die->HasChildren();
type_sp.reset (new Type (die->GetOffset(),
this,
type_name_const_str,
@@ -2984,7 +2967,7 @@
Type::eEncodingIsUID,
&decl,
clang_type,
- is_forward_decl));
+ Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
@@ -3013,9 +2996,7 @@
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
- size_t byte_size = 0;
lldb::user_id_t encoding_uid = DW_INVALID_OFFSET;
- Declaration decl;
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
if (num_attributes > 0)
@@ -3086,7 +3067,7 @@
Type::eEncodingIsUID,
&decl,
clang_type,
- true));
+ Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
@@ -3111,7 +3092,6 @@
const char *mangled = NULL;
dw_offset_t type_die_offset = DW_INVALID_OFFSET;
- Declaration decl;
bool is_variadic = false;
bool is_inline = false;
bool is_static = false;
@@ -3202,7 +3182,7 @@
func_type = ResolveTypeUID(type_die_offset);
if (func_type)
- return_clang_type = func_type->GetClangForwardType();
+ return_clang_type = func_type->GetClangLayoutType();
else
return_clang_type = ast.GetBuiltInType_void();
@@ -3339,7 +3319,7 @@
Type::eEncodingIsUID,
&decl,
clang_type,
- false));
+ Type::eResolveStateFull));
m_die_to_type[die] = type_sp.get();
assert(type_sp.get());
@@ -3351,9 +3331,7 @@
// Set a bit that lets us know that we are currently parsing this
m_die_to_type[die] = DIE_IS_BEING_PARSED;
- size_t byte_size = 0;
lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
- Declaration decl;
int64_t first_index = 0;
uint32_t byte_stride = 0;
uint32_t bit_stride = 0;
@@ -3432,11 +3410,12 @@
empty_name,
array_element_bit_stride / 8,
NULL,
- LLDB_INVALID_UID,
+ type_die_offset,
Type::eEncodingIsUID,
&decl,
clang_type,
- false));
+ Type::eResolveStateFull));
+ type_sp->SetEncodingType (element_type);
m_die_to_type[die] = type_sp.get();
}
}
@@ -3471,14 +3450,14 @@
Type *pointee_type = ResolveTypeUID(type_die_offset);
Type *class_type = ResolveTypeUID(containing_type_die_offset);
- clang_type_t pointee_clang_type = pointee_type->GetClangType();
- clang_type_t class_clang_type = class_type->GetClangType();
+ clang_type_t pointee_clang_type = pointee_type->GetClangForwardType();
+ clang_type_t class_clang_type = class_type->GetClangLayoutType();
clang_type = ast.CreateMemberPointerType(pointee_clang_type,
class_clang_type);
- size_t byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(),
- clang_type) / 8;
+ byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(),
+ clang_type) / 8;
type_sp.reset( new Type (die->GetOffset(),
this,
@@ -3489,7 +3468,7 @@
Type::eEncodingIsUID,
NULL,
clang_type,
- false));
+ Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index a92fbdd..1106b24 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -110,7 +110,7 @@
virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types);
// virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types);
virtual lldb_private::TypeList *GetTypeList ();
- virtual clang::NamespaceDecl *
+ virtual lldb_private::ClangNamespaceDecl
FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 7d4607e..a8f3763 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -953,11 +953,11 @@
//}
-clang::NamespaceDecl *
+ClangNamespaceDecl
SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name)
{
- clang::NamespaceDecl *matching_namespace = NULL;
+ ClangNamespaceDecl matching_namespace;
SymbolFileDWARF *oso_dwarf;
if (sc.comp_unit)
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 88aceb2..5ab88dc 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -71,7 +71,7 @@
virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types);
// virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types);
- virtual clang::NamespaceDecl *
+ virtual lldb_private::ClangNamespaceDecl
FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name);
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 9a8d6f3..56141bc 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -277,10 +277,10 @@
return NULL;
}
-clang::NamespaceDecl *
+ClangNamespaceDecl
SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name)
{
- return NULL;
+ return ClangNamespaceDecl();
}
uint32_t
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index 0bd4e7f..fc6a52c 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -101,7 +101,7 @@
// virtual uint32_t
// FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::TypeList& types);
- virtual clang::NamespaceDecl *
+ virtual lldb_private::ClangNamespaceDecl
FindNamespace (const lldb_private::SymbolContext& sc,
const lldb_private::ConstString &name);
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 363b1af..a7fe230 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -740,6 +740,23 @@
return dst.getAsOpaquePtr();
}
+
+clang::Decl *
+ClangASTContext::CopyDecl (ASTContext *dest_context,
+ ASTContext *source_context,
+ clang::Decl *source_decl)
+{
+ // null_client's ownership is transferred to diagnostics
+ NullDiagnosticClient *null_client = new NullDiagnosticClient;
+ Diagnostic diagnostics(null_client);
+ FileManager file_manager;
+ ASTImporter importer(diagnostics,
+ *dest_context, file_manager,
+ *source_context, file_manager);
+
+ return importer.Import(source_decl);
+}
+
bool
ClangASTContext::AreTypesSame(ASTContext *ast_context,
clang_type_t type1,
diff --git a/source/Symbol/ClangNamespaceDecl.cpp b/source/Symbol/ClangNamespaceDecl.cpp
new file mode 100644
index 0000000..9e764ba
--- /dev/null
+++ b/source/Symbol/ClangNamespaceDecl.cpp
@@ -0,0 +1,11 @@
+//===-- ClangNamespaceDecl.cpp ----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/ClangNamespaceDecl.h"
+
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index e89782d..373d5e6 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -413,8 +413,18 @@
CalculateSymbolContext (&sc);
// Null out everything below the CompUnit 'cause we don't actually know these.
- size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), fun_return_qualtype.getAsOpaquePtr());
- Type return_type (0, GetType()->GetSymbolFile(), fun_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), fun_return_qualtype.getAsOpaquePtr(), false);
+ size_t bit_size = ClangASTType::GetClangTypeBitWidth (GetType()->GetClangASTContext().getASTContext(),
+ fun_return_qualtype.getAsOpaquePtr());
+ Type return_type (0,
+ GetType()->GetSymbolFile(),
+ fun_return_name,
+ bit_size,
+ sc.comp_unit,
+ 0,
+ Type::eEncodingIsSyntheticUID,
+ Declaration(),
+ fun_return_qualtype.getAsOpaquePtr(),
+ Type::eResolveStateFull);
return return_type;
}
@@ -455,7 +465,16 @@
// Null out everything below the CompUnit 'cause we don't actually know these.
size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), arg_qualtype.getAsOpaquePtr());
- Type arg_type (0, GetType()->GetSymbolFile(), arg_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), arg_qualtype.getAsOpaquePtr(), false);
+ Type arg_type (0,
+ GetType()->GetSymbolFile(),
+ arg_return_name,
+ bit_size,
+ sc.comp_unit,
+ 0,
+ Type::eEncodingIsSyntheticUID,
+ Declaration(),
+ arg_qualtype.getAsOpaquePtr(),
+ Type::eResolveStateFull);
return arg_type;
}
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index 2ac99a0..2f5ff3a 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -400,6 +400,14 @@
return false;
}
+ClangNamespaceDecl
+SymbolContext::FindNamespace (const ConstString &name) const
+{
+ ClangNamespaceDecl namespace_decl;
+ if (module_sp)
+ namespace_decl = module_sp->GetSymbolVendor()->FindNamespace (*this, name);
+ return namespace_decl;
+}
size_t
SymbolContext::FindFunctionsByName (const ConstString &name, bool append, SymbolContextList &sc_list) const
@@ -422,12 +430,12 @@
return sc_list.GetSize();
}
-lldb::VariableSP
-SymbolContext::FindVariableByName (const char *name) const
-{
- lldb::VariableSP return_value;
- return return_value;
-}
+//lldb::VariableSP
+//SymbolContext::FindVariableByName (const char *name) const
+//{
+// lldb::VariableSP return_value;
+// return return_value;
+//}
lldb::TypeSP
SymbolContext::FindTypeByName (const ConstString &name) const
diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp
index d960dde..f2a3681 100644
--- a/source/Symbol/SymbolVendor.cpp
+++ b/source/Symbol/SymbolVendor.cpp
@@ -261,22 +261,16 @@
types.Clear();
return 0;
}
-//
-//uint32_t
-//SymbolVendor::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& types)
-//{
-// Mutex::Locker locker(m_mutex);
-// if (m_sym_file_ap.get())
-// {
-// lldb::user_id_t udt_uid = LLDB_INVALID_UID;
-//
-// if (encoding == Type::user_defined_type)
-// udt_uid = UserDefType::GetUserDefTypeUID(udt_name);
-//
-// return m_sym_file_ap->FindTypes(sc, regex, append, max_matches, encoding, udt_uid, types);
-// }
-// return 0;
-//}
+
+ClangNamespaceDecl
+SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name)
+{
+ Mutex::Locker locker(m_mutex);
+ ClangNamespaceDecl namespace_decl;
+ if (m_sym_file_ap.get())
+ namespace_decl = m_sym_file_ap->FindNamespace (sc, name);
+ return namespace_decl;
+}
void
SymbolVendor::Dump(Stream *s)
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 111ec89..e99b1a0 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -39,7 +39,7 @@
EncodingDataType encoding_data_type,
const Declaration& decl,
clang_type_t clang_type,
- bool is_forward_decl
+ ResolveState clang_type_resolve_state
) :
UserID (uid),
m_name (name),
@@ -51,9 +51,7 @@
m_byte_size (byte_size),
m_decl (decl),
m_clang_type (clang_type),
- m_is_forward_decl (is_forward_decl),
- m_encoding_type_forward_decl_resolved (false),
- m_encoding_type_decl_resolved (false)
+ m_clang_type_resolve_state (clang_type ? clang_type_resolve_state : eResolveStateUnresolved)
{
}
@@ -66,9 +64,9 @@
m_encoding_uid_type (eEncodingInvalid),
m_encoding_uid (0),
m_byte_size (0),
- m_is_forward_decl (false),
m_decl (),
- m_clang_type (NULL)
+ m_clang_type (NULL),
+ m_clang_type_resolve_state (eResolveStateUnresolved)
{
}
@@ -86,9 +84,9 @@
m_encoding_uid_type = rhs.m_encoding_uid_type;
m_encoding_uid = rhs.m_encoding_uid;
m_byte_size = rhs.m_byte_size;
- m_is_forward_decl = rhs.m_is_forward_decl;
m_decl = rhs.m_decl;
m_clang_type = rhs.m_clang_type;
+ m_clang_type_resolve_state = rhs.m_clang_type_resolve_state;
}
return *this;
}
@@ -190,7 +188,7 @@
{
if (!(m_name))
{
- if (ResolveClangType(true))
+ if (ResolveClangType(eResolveStateForward))
{
std::string type_name = ClangASTContext::GetTypeName (m_clang_type);
if (!type_name.empty())
@@ -220,7 +218,7 @@
lldb::Format format
)
{
- if (ResolveClangType(true))
+ if (ResolveClangType(eResolveStateForward))
{
if (show_types)
{
@@ -251,11 +249,8 @@
lldb_private::Type *
lldb_private::Type::GetEncodingType ()
{
- if (m_encoding_type == NULL)
- {
- if (m_encoding_uid != LLDB_INVALID_UID)
- m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
- }
+ if (m_encoding_type == NULL && m_encoding_uid != LLDB_INVALID_UID)
+ m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid);
return m_encoding_type;
}
@@ -279,7 +274,7 @@
m_byte_size = encoding_type->GetByteSize();
if (m_byte_size == 0)
{
- uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType());
+ uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangLayoutType());
m_byte_size = (bit_width + 7 ) / 8;
}
}
@@ -300,7 +295,7 @@
uint32_t
lldb_private::Type::GetNumChildren (bool omit_empty_base_classes)
{
- if (!ResolveClangType())
+ if (!ResolveClangType(eResolveStateFull))
return 0;
return ClangASTContext::GetNumChildren (m_clang_type, omit_empty_base_classes);
@@ -309,7 +304,7 @@
bool
lldb_private::Type::IsAggregateType ()
{
- if (ResolveClangType())
+ if (ResolveClangType(eResolveStateForward))
return ClangASTContext::IsAggregateType (m_clang_type);
return false;
}
@@ -318,7 +313,7 @@
lldb_private::Type::GetFormat ()
{
// Make sure we resolve our type if it already hasn't been.
- if (!ResolveClangType())
+ if (!ResolveClangType(eResolveStateForward))
return lldb::eFormatInvalid;
return lldb_private::ClangASTType::GetFormat (m_clang_type);
}
@@ -329,7 +324,7 @@
lldb_private::Type::GetEncoding (uint32_t &count)
{
// Make sure we resolve our type if it already hasn't been.
- if (!ResolveClangType())
+ if (!ResolveClangType(eResolveStateForward))
return lldb::eEncodingInvalid;
return lldb_private::ClangASTType::GetEncoding (m_clang_type, count);
@@ -422,18 +417,23 @@
}
bool
-lldb_private::Type::ResolveClangType (bool forward_decl_is_ok)
+lldb_private::Type::ResolveClangType (ResolveState clang_type_resolve_state)
{
+ Type *encoding_type = NULL;
if (m_clang_type == NULL)
{
TypeList *type_list = GetTypeList();
- Type *encoding_type = GetEncodingType();
+ encoding_type = GetEncodingType();
if (encoding_type)
{
switch (m_encoding_uid_type)
{
case eEncodingIsUID:
- m_clang_type = encoding_type->GetClangType();
+ if (encoding_type->ResolveClangType(clang_type_resolve_state))
+ {
+ m_clang_type = encoding_type->m_clang_type;
+ m_clang_type_resolve_state = encoding_type->m_clang_type_resolve_state;
+ }
break;
case eEncodingIsConstUID:
@@ -518,11 +518,9 @@
}
// Check if we have a forward reference to a class/struct/union/enum?
- if (m_clang_type != NULL &&
- m_is_forward_decl == true &&
- forward_decl_is_ok == false)
+ if (m_clang_type && m_clang_type_resolve_state < clang_type_resolve_state)
{
- m_is_forward_decl = false;
+ m_clang_type_resolve_state = eResolveStateFull;
if (!ClangASTType::IsDefined (m_clang_type))
{
// We have a forward declaration, we need to resolve it to a complete
@@ -533,45 +531,25 @@
// If we have an encoding type, then we need to make sure it is
// resolved appropriately.
- if (m_encoding_type_decl_resolved == false)
+ if (m_encoding_uid != LLDB_INVALID_UID)
{
- if ((forward_decl_is_ok == true && !m_encoding_type_forward_decl_resolved) ||
- (forward_decl_is_ok == false))
+ if (encoding_type == NULL)
+ encoding_type = GetEncodingType();
+ if (encoding_type)
{
- Type *encoding_type = GetEncodingType ();
- if (encoding_type != NULL)
+ ResolveState encoding_clang_type_resolve_state = eResolveStateFull;
+ switch (m_encoding_uid_type)
{
- bool forward_decl_is_ok_for_encoding = forward_decl_is_ok;
-// switch (m_encoding_uid_type)
-// {
-// case eEncodingIsPointerUID:
-// case eEncodingIsLValueReferenceUID:
-// case eEncodingIsRValueReferenceUID:
-// forward_decl_is_ok_for_encoding = true;
-// break;
-// default:
-// break;
-// }
-
- if (encoding_type->ResolveClangType (forward_decl_is_ok_for_encoding))
- {
- // We have at least resolve the forward declaration for our
- // encoding type...
- m_encoding_type_forward_decl_resolved = true;
-
- // Check if we fully resolved our encoding type, and if so
- // mark it as having been completely resolved.
- if (forward_decl_is_ok_for_encoding == false)
- m_encoding_type_decl_resolved = true;
- }
+ case eEncodingIsPointerUID:
+ case eEncodingIsLValueReferenceUID:
+ case eEncodingIsRValueReferenceUID:
+ if (clang_type_resolve_state == eResolveStateLayout)
+ encoding_clang_type_resolve_state = eResolveStateForward;
+ break;
+ default:
+ break;
}
- else
- {
- // We don't have an encoding type, so mark everything as being
- // resolved so we don't get into this if statement again
- m_encoding_type_decl_resolved = true;
- m_encoding_type_forward_decl_resolved = true;
- }
+ encoding_type->ResolveClangType (encoding_clang_type_resolve_state);
}
}
return m_clang_type != NULL;
@@ -592,29 +570,30 @@
bool &child_is_base_class
)
{
- if (!ResolveClangType())
- return NULL;
-
- std::string name_str;
- clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (
- parent_name,
- m_clang_type,
- idx,
- transparent_pointers,
- omit_empty_base_classes,
- name_str,
- child_byte_size,
- child_byte_offset,
- child_bitfield_bit_size,
- child_bitfield_bit_offset,
- child_is_base_class);
-
- if (child_qual_type)
+ clang_type_t child_qual_type = NULL;
+
+ if (GetClangType())
{
- if (!name_str.empty())
- name.SetCString(name_str.c_str());
- else
- name.Clear();
+ std::string name_str;
+ child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (parent_name,
+ m_clang_type,
+ idx,
+ transparent_pointers,
+ omit_empty_base_classes,
+ name_str,
+ child_byte_size,
+ child_byte_offset,
+ child_bitfield_bit_size,
+ child_bitfield_bit_offset,
+ child_is_base_class);
+
+ if (child_qual_type)
+ {
+ if (!name_str.empty())
+ name.SetCString(name_str.c_str());
+ else
+ name.Clear();
+ }
}
return child_qual_type;
}
@@ -623,16 +602,21 @@
clang_type_t
lldb_private::Type::GetClangType ()
{
- const bool forward_decl_is_ok = false;
- ResolveClangType(forward_decl_is_ok);
+ ResolveClangType(eResolveStateFull);
+ return m_clang_type;
+}
+
+clang_type_t
+lldb_private::Type::GetClangLayoutType ()
+{
+ ResolveClangType(eResolveStateLayout);
return m_clang_type;
}
clang_type_t
lldb_private::Type::GetClangForwardType ()
{
- const bool forward_decl_is_ok = true;
- ResolveClangType (forward_decl_is_ok);
+ ResolveClangType (eResolveStateForward);
return m_clang_type;
}
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index f77d0fa..665aac5 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -245,7 +245,7 @@
{
Value value;
value.SetValueType (Value::eValueTypeScalar);
- value.SetContext (Value::eContextTypeOpaqueClangQualType, m_intptr_type.GetOpaqueQualType());
+ value.SetContext (Value::eContextTypeClangType, m_intptr_type.GetOpaqueQualType());
value_list.PushValue (value);
}