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.

llvm-svn: 118976
This commit is contained in:
Greg Clayton 2010-11-13 03:52:47 +00:00
parent f01b622902
commit 526e5afb2d
40 changed files with 471 additions and 292 deletions

View File

@ -134,8 +134,8 @@ public:
/// @endcode
///
/// @return
/// A pointer to this object if the string isn't empty, NULL
/// otherwise.
/// /b True this object contains a valid non-empty C string, \b
/// false otherwise.
//------------------------------------------------------------------
operator bool() const
{

View File

@ -44,10 +44,10 @@ public:
// m_context contains...
// ====================
eContextTypeInvalid, // undefined
eContextTypeOpaqueClangQualType,// void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)")
eContextTypeDCRegisterInfo, // lldb::RegisterInfo *
eContextTypeDCType, // Type *
eContextTypeDCVariable, // Variable *
eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)")
eContextTypeRegisterInfo, // lldb::RegisterInfo *
eContextTypeLLDBType, // lldb_private::Type *
eContextTypeVariable, // lldb_private::Variable *
eContextTypeValue // Value * (making this a proxy value. Used when putting locals on the DWARF expression parser stack)
};

View File

@ -93,6 +93,10 @@ public:
const ConstString &
GetPersistentResultName ();
clang::NamespaceDecl *
AddNamespace (NameSearchContext &context,
const ClangNamespaceDecl &namespace_decl);
//------------------------------------------------------------------
/// [Used by IRForTarget] Add a variable to the list of persistent
/// variables for the process.

View File

@ -144,6 +144,11 @@ public:
clang::ASTContext *source_context,
lldb::clang_type_t clang_type);
static clang::Decl *
CopyDecl (clang::ASTContext *dest_context,
clang::ASTContext *source_context,
clang::Decl *source_decl);
static bool
AreTypesSame(clang::ASTContext *ast_context,
lldb::clang_type_t type1,

View File

@ -0,0 +1,100 @@
//===-- ClangNamespaceDecl.h ------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ClangNamespaceDecl_h_
#define liblldb_ClangNamespaceDecl_h_
#include "lldb/lldb-include.h"
#include "lldb/Core/ClangForward.h"
namespace lldb_private {
class ClangNamespaceDecl
{
public:
ClangNamespaceDecl () :
m_ast (NULL),
m_namespace_decl (NULL)
{
}
ClangNamespaceDecl (clang::ASTContext *ast, clang::NamespaceDecl *namespace_decl) :
m_ast (ast),
m_namespace_decl (namespace_decl)
{
}
ClangNamespaceDecl (const ClangNamespaceDecl &rhs) :
m_ast (rhs.m_ast),
m_namespace_decl (rhs.m_namespace_decl)
{
}
const ClangNamespaceDecl &
operator = (const ClangNamespaceDecl &rhs)
{
m_ast = rhs.m_ast;
m_namespace_decl = rhs.m_namespace_decl;
return *this;
}
//------------------------------------------------------------------
/// Convert to bool operator.
///
/// This allows code to check a ClangNamespaceDecl object to see if
/// it contains a valid namespace decl using code such as:
///
/// @code
/// ClangNamespaceDecl ns_decl(...);
/// if (ns_decl)
/// { ...
/// @endcode
///
/// @return
/// /b True this object contains a valid namespace decl, \b
/// false otherwise.
//------------------------------------------------------------------
operator bool() const
{
return m_ast != NULL && m_namespace_decl != NULL;
}
clang::ASTContext *
GetASTContext() const
{
return m_ast;
}
void
SetASTContext (clang::ASTContext *ast)
{
m_ast = ast;
}
clang::NamespaceDecl *
GetNamespaceDecl () const
{
return m_namespace_decl;
}
void
SetNamespaceDecl (clang::NamespaceDecl *namespace_decl)
{
m_namespace_decl = namespace_decl;
}
protected:
clang::ASTContext *m_ast;
clang::NamespaceDecl *m_namespace_decl;
};
} // namespace lldb_private
#endif // #ifndef liblldb_ClangNamespaceDecl_h_

View File

@ -15,6 +15,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/LineEntry.h"
namespace lldb_private {
@ -208,6 +209,10 @@ public:
bool append,
SymbolContextList &sc_list) const;
ClangNamespaceDecl
FindNamespace (const ConstString &name) const;
//------------------------------------------------------------------
/// Find a variable matching the given name, working out from this
/// symbol context.
@ -215,8 +220,8 @@ public:
/// @return
/// A shared pointer to the variable found.
//------------------------------------------------------------------
lldb::VariableSP
FindVariableByName (const char *name) const;
//lldb::VariableSP
//FindVariableByName (const char *name) const;
//------------------------------------------------------------------
/// Find a type matching the given name, working out from this

View File

@ -12,6 +12,8 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/Type.h"
namespace lldb_private {
@ -81,7 +83,7 @@ public:
virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0;
// virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
virtual TypeList * GetTypeList ();
virtual clang::NamespaceDecl *
virtual ClangNamespaceDecl
FindNamespace (const SymbolContext& sc,
const ConstString &name) = 0;

View File

@ -16,6 +16,7 @@
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ClangNamespaceDecl.h"
#include "lldb/Symbol/TypeList.h"
@ -126,12 +127,9 @@ public:
uint32_t max_matches,
TypeList& types);
// virtual uint32_t
// FindTypes (const SymbolContext& sc,
// const RegularExpression& regex,
// bool append,
// uint32_t max_matches,
// TypeList& types);
virtual lldb_private::ClangNamespaceDecl
FindNamespace (const SymbolContext& sc,
const ConstString &name);
virtual uint32_t
GetNumCompileUnits();

View File

@ -21,7 +21,7 @@ namespace lldb_private {
class Type : public UserID
{
public:
typedef enum
typedef enum EncodingDataTypeTag
{
eEncodingInvalid,
eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid
@ -35,6 +35,14 @@ public:
eEncodingIsSyntheticUID
} EncodingDataType;
typedef enum ResolveStateTag
{
eResolveStateUnresolved = 0,
eResolveStateForward = 1,
eResolveStateLayout = 2,
eResolveStateFull = 3
} ResolveState;
Type (lldb::user_id_t uid,
SymbolFile* symbol_file,
const ConstString &name,
@ -44,7 +52,7 @@ public:
EncodingDataType encoding_type,
const Declaration& decl,
lldb::clang_type_t clang_qual_type,
bool is_forward_decl);
ResolveState clang_type_resolve_state);
// This makes an invalid type. Used for functions that return a Type when they
// get an error.
@ -177,6 +185,12 @@ public:
lldb::clang_type_t
GetClangType ();
// Get the clang type, and resolve definitions enough so that the type could
// have layout performed. This allows ptrs and refs to class/struct/union/enum
// types remain forward declarations.
lldb::clang_type_t
GetClangLayoutType ();
// Get the clang type and leave class/struct/union/enum types as forward
// declarations if they haven't already been fully defined.
lldb::clang_type_t
@ -203,6 +217,12 @@ public:
static int
Compare(const Type &a, const Type &b);
void
SetEncodingType (Type *encoding_type)
{
m_encoding_type = encoding_type;
}
protected:
ConstString m_name;
SymbolFile *m_symbol_file;
@ -213,14 +233,12 @@ protected:
uint32_t m_byte_size;
Declaration m_decl;
lldb::clang_type_t m_clang_type;
bool m_is_forward_decl:1,
m_encoding_type_forward_decl_resolved:1,
m_encoding_type_decl_resolved:1;
ResolveState m_clang_type_resolve_state;
Type *
GetEncodingType ();
bool ResolveClangType(bool forward_decl_is_ok = false);
bool ResolveClangType (ResolveState clang_type_resolve_state);
};
} // namespace lldb_private

View File

@ -41,6 +41,8 @@ class BreakpointSiteList;
class Broadcaster;
class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTType;
class ClangNamespaceDecl;
class ClangExpression;
class ClangExpressionDeclMap;
class ClangExpressionVariable;

View File

@ -63,6 +63,8 @@
26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; };
26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; };
2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; };
266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */; };
266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */; };
268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; };
268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; };
26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -567,6 +569,8 @@
266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "edit-swig-python-wrapper-file.py"; sourceTree = "<group>"; };
266960621199F4230075C61A /* finish-swig-Python-lldb.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "finish-swig-Python-lldb.sh"; sourceTree = "<group>"; };
266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = "<group>"; };
266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = "<group>"; };
266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = "<group>"; };
2672D8461189055500FF4019 /* CommandObjectFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectFrame.cpp; path = source/Commands/CommandObjectFrame.cpp; sourceTree = "<group>"; };
2672D8471189055500FF4019 /* CommandObjectFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectFrame.h; path = source/Commands/CommandObjectFrame.h; sourceTree = "<group>"; };
2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = "<group>"; };
@ -1783,6 +1787,8 @@
26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */,
49E45FA911F660DC008F7B28 /* ClangASTType.h */,
49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */,
266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */,
266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */,
26BC7C5710F1B6E900F91463 /* CompileUnit.h */,
26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */,
26BC7C5810F1B6E900F91463 /* Declaration.h */,
@ -2374,6 +2380,7 @@
4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */,
4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */,
4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */,
266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2445,6 +2452,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
@ -2876,6 +2884,7 @@
4C61978C12823D4300FAFFCC /* AppleObjCRuntime.cpp in Sources */,
4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */,
4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */,
266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2933,7 +2942,6 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
VALID_ARCHS = "x86_64 i386";
};
@ -2964,7 +2972,6 @@
26579F6A126A25920007C5CB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;

View File

@ -249,7 +249,7 @@ CommandObjectArgs::Execute
return false;
}
value.SetContext (Value::eContextTypeOpaqueClangQualType, type);
value.SetContext (Value::eContextTypeClangType, type);
value_list.PushValue(value);
}

View File

@ -257,7 +257,7 @@ CommandObjectCall::Execute
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;

View File

@ -287,7 +287,7 @@ Value::GetRegisterInfo()
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 @@ Value::GetType()
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 @@ Value::ValueOf(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
{
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 @@ Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
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 @@ Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
}
break;
case eContextTypeDCRegisterInfo: // RegisterInfo *
case eContextTypeRegisterInfo: // RegisterInfo *
if (GetRegisterInfo())
byte_size = GetRegisterInfo()->byte_size;
else if (error_ptr)
@ -386,14 +386,14 @@ Value::GetValueByteSize (clang::ASTContext *ast_context, Error *error_ptr)
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 @@ Value::GetClangType ()
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 @@ Value::GetValueDefaultFormat ()
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 @@ Value::ResolveValue(ExecutionContext *exe_ctx, clang::ASTContext *ast_context)
}
}
if (m_context_type == eContextTypeOpaqueClangQualType)
if (m_context_type == eContextTypeClangType)
{
void *opaque_clang_qual_type = GetClangType();
switch (m_value_type)
@ -731,7 +731,7 @@ Value::GetVariable()
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 @@ Value::GetContextTypeAsCString (ContextType context_type)
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 "???";

View File

@ -179,7 +179,7 @@ ValueObject::GetLocationAsCString (ExecutionContextScope *exe_scope)
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 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
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 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope)
}
break;
case Value::eContextTypeDCRegisterInfo:
case Value::eContextTypeRegisterInfo:
{
const RegisterInfo *reg_info = m_value.GetRegisterInfo();
if (reg_info)

View File

@ -135,7 +135,7 @@ ValueObjectChild::UpdateValue (ExecutionContextScope *exe_scope)
{
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();

View File

@ -44,7 +44,7 @@ ValueObjectConstResult::ValueObjectConstResult
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);

View File

@ -319,7 +319,7 @@ ValueObjectRegister::UpdateValue (ExecutionContextScope *exe_scope)
{
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);

View File

@ -120,7 +120,7 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope)
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 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope)
// 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;

View File

@ -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 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
break;
case Value::eValueTypeScalar:
{
if (location_value->GetContextType() != Value::eContextTypeDCRegisterInfo)
if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
{
StreamString ss;
@ -1019,6 +1020,18 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
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 @@ ClangExpressionDeclMap::GetVariableValue
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 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
}
}
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,

View File

@ -83,7 +83,7 @@ ClangExpressionVariable::PointValueAtData(Value &value, ExecutionContext *exe_ct
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();

View File

@ -327,7 +327,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
// 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 @@ ClangFunction::FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t arg
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;

View File

@ -658,7 +658,7 @@ ReadRegisterValueAsScalar
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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 @@ DWARFExpression::Evaluate
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;
//----------------------------------------------------------------------

View File

@ -234,7 +234,7 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread,
{
default:
return false;
case Value::eContextTypeOpaqueClangQualType:
case Value::eContextTypeClangType:
{
void *val_type = val->GetClangType();
uint32_t cstr_length;
@ -433,7 +433,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
{
default:
return false;
case Value::eContextTypeOpaqueClangQualType:
case Value::eContextTypeClangType:
{
void *value_type = value->GetClangType();
bool is_signed;
@ -472,7 +472,7 @@ ABIMacOSX_i386::GetReturnValue (Thread &thread,
{
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

View File

@ -304,7 +304,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread,
{
default:
return false;
case Value::eContextTypeOpaqueClangQualType:
case Value::eContextTypeClangType:
{
void *value_type = value->GetClangType();
bool is_signed;
@ -347,7 +347,7 @@ ABISysV_x86_64::GetReturnValue (Thread &thread,
{
default:
return false;
case Value::eContextTypeOpaqueClangQualType:
case Value::eContextTypeClangType:
{
void *value_type = value.GetClangType();
bool is_signed;

View File

@ -97,7 +97,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont
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 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont
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);

View File

@ -74,15 +74,15 @@ AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::SetUpRegion()
}
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 @@ AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::SetUpRegion()
// 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 @@ AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines (void *baton,
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 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
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;

View File

@ -1158,7 +1158,7 @@ SymbolFileDWARF::ParseChildMembers
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 @@ SymbolFileDWARF::ParseChildMembers
}
}
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,14 +2100,14 @@ SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, boo
}
clang::NamespaceDecl *
ClangNamespaceDecl
SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
const ConstString &name)
{
ClangNamespaceDecl namespace_decl;
DWARFDebugInfo* info = DebugInfo();
if (info == NULL)
return 0;
if (info)
{
// Index if we already haven't to make sure the compile units
// get indexed and make their global DIE index list
if (!m_indexed)
@ -2127,9 +2127,15 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc,
die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
return ResolveNamespaceDIE (curr_cu, die);
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
encoding_data_type,
&decl,
clang_type,
clang_type == NULL));
resolve_state));
m_die_to_type[die] = type_sp.get();
@ -2853,10 +2839,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
// 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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
// 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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
Type::eEncodingIsUID,
&decl,
clang_type,
is_forward_decl));
Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
@ -3013,9 +2996,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
// 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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
Type::eEncodingIsUID,
&decl,
clang_type,
true));
Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
@ -3111,7 +3092,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
Type::eEncodingIsUID,
&decl,
clang_type,
false));
Type::eResolveStateFull));
m_die_to_type[die] = type_sp.get();
assert(type_sp.get());
@ -3351,9 +3331,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
// 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 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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,13 +3450,13 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
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(),
byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(),
clang_type) / 8;
type_sp.reset( new Type (die->GetOffset(),
@ -3489,7 +3468,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
Type::eEncodingIsUID,
NULL,
clang_type,
false));
Type::eResolveStateForward));
m_die_to_type[die] = type_sp.get();
}

View File

@ -110,7 +110,7 @@ public:
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);

View File

@ -953,11 +953,11 @@ SymbolFileDWARFDebugMap::FindTypes
//}
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)

View File

@ -71,7 +71,7 @@ public:
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);

View File

@ -277,10 +277,10 @@ SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Typ
return NULL;
}
clang::NamespaceDecl *
ClangNamespaceDecl
SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name)
{
return NULL;
return ClangNamespaceDecl();
}
uint32_t

View File

@ -101,7 +101,7 @@ public:
// 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);

View File

@ -740,6 +740,23 @@ ClangASTContext::CopyType (ASTContext *dest_context,
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,

View File

@ -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"

View File

@ -413,8 +413,18 @@ Function::GetReturnType ()
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 @@ Function::GetArgumentTypeAtIndex (size_t idx)
// 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;
}

View File

@ -400,6 +400,14 @@ SymbolContext::GetAddressRange (uint32_t scope, AddressRange &range) const
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 @@ SymbolContext::FindFunctionsByName (const ConstString &name, bool append, Symbol
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

View File

@ -261,22 +261,16 @@ SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, bool
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)

View File

@ -39,7 +39,7 @@ lldb_private::Type::Type
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 @@ lldb_private::Type::Type
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 @@ lldb_private::Type::Type () :
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 @@ lldb_private::Type::operator= (const Type& rhs)
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 @@ lldb_private::Type::GetName()
{
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_private::Type::DumpValue
lldb::Format format
)
{
if (ResolveClangType(true))
if (ResolveClangType(eResolveStateForward))
{
if (show_types)
{
@ -251,11 +249,8 @@ lldb_private::Type::DumpValue
lldb_private::Type *
lldb_private::Type::GetEncodingType ()
{
if (m_encoding_type == NULL)
{
if (m_encoding_uid != LLDB_INVALID_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 @@ lldb_private::Type::GetByteSize()
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 @@ lldb_private::Type::GetByteSize()
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 @@ lldb_private::Type::GetNumChildren (bool omit_empty_base_classes)
bool
lldb_private::Type::IsAggregateType ()
{
if (ResolveClangType())
if (ResolveClangType(eResolveStateForward))
return ClangASTContext::IsAggregateType (m_clang_type);
return false;
}
@ -318,7 +313,7 @@ lldb::Format
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::Encoding
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 @@ lldb_private::Type::GetDeclaration () const
}
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 @@ lldb_private::Type::ResolveClangType (bool forward_decl_is_ok)
}
// 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 @@ lldb_private::Type::ResolveClangType (bool forward_decl_is_ok)
// 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;
}
}
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;
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID:
if (clang_type_resolve_state == eResolveStateLayout)
encoding_clang_type_resolve_state = eResolveStateForward;
break;
default:
break;
}
encoding_type->ResolveClangType (encoding_clang_type_resolve_state);
}
}
return m_clang_type != NULL;
@ -592,12 +570,12 @@ lldb_private::Type::GetChildClangTypeAtIndex
bool &child_is_base_class
)
{
if (!ResolveClangType())
return NULL;
clang_type_t child_qual_type = NULL;
if (GetClangType())
{
std::string name_str;
clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (
parent_name,
child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (parent_name,
m_clang_type,
idx,
transparent_pointers,
@ -616,6 +594,7 @@ lldb_private::Type::GetChildClangTypeAtIndex
else
name.Clear();
}
}
return child_qual_type;
}
@ -623,16 +602,21 @@ lldb_private::Type::GetChildClangTypeAtIndex
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;
}

View File

@ -245,7 +245,7 @@ void ThreadPlanAssemblyTracer::Log ()
{
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);
}