summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-10-27 02:54:13 +0000
committerJim Ingham <jingham@apple.com>2012-10-27 02:54:13 +0000
commit3793976376acc29c0b302c228c079d85c75cbffb (patch)
treee10218cf5b7b3867aa94474d36dbd351f3c5a16b
parent4dc613b364296d57d8d12cb2f1285d54b21064f1 (diff)
downloadbcm5719-llvm-3793976376acc29c0b302c228c079d85c75cbffb.tar.gz
bcm5719-llvm-3793976376acc29c0b302c228c079d85c75cbffb.zip
This is the first phase of supporting the DW_AT_object_pointer tag. I expanded the decl metadata
so it could hold this information, and then used it to look up unfound names in the object pointer if it exists. This gets "frame var" to work for unqualified references to ivars captured in blocks. But the expression parser is ignoring this information still. llvm-svn: 166860
-rw-r--r--lldb/include/lldb/Expression/ClangASTSource.h5
-rw-r--r--lldb/include/lldb/Symbol/ClangASTContext.h22
-rw-r--r--lldb/include/lldb/Symbol/ClangASTImporter.h2
-rw-r--r--lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h96
-rw-r--r--lldb/include/lldb/lldb-forward.h1
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp3
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp17
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp100
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp5
-rw-r--r--lldb/source/Symbol/ClangASTContext.cpp51
-rw-r--r--lldb/source/Symbol/ClangASTImporter.cpp20
-rw-r--r--lldb/source/Symbol/ClangExternalASTSourceCommon.cpp14
12 files changed, 270 insertions, 66 deletions
diff --git a/lldb/include/lldb/Expression/ClangASTSource.h b/lldb/include/lldb/Expression/ClangASTSource.h
index 27190346d27..95bbba36f74 100644
--- a/lldb/include/lldb/Expression/ClangASTSource.h
+++ b/lldb/include/lldb/Expression/ClangASTSource.h
@@ -296,12 +296,13 @@ public:
return m_original.StartTranslationUnit(Consumer);
}
- uint64_t GetMetadata(uintptr_t object)
+ ClangASTMetadata *
+ GetMetadata(uintptr_t object)
{
return m_original.GetMetadata(object);
}
- void SetMetadata(uintptr_t object, uint64_t metadata)
+ void SetMetadata(uintptr_t object, ClangASTMetadata &metadata)
{
return m_original.SetMetadata(object, metadata);
}
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index a7d15c1c095..ac09cb0a3db 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -144,23 +144,27 @@ public:
GetCompleteDecl (clang::ASTContext *ast,
clang::Decl *decl);
+ void SetMetadataAsUserID (uintptr_t object,
+ lldb::user_id_t user_id);
+
void SetMetadata (uintptr_t object,
- uint64_t metadata)
+ ClangASTMetadata &meta_data)
{
- SetMetadata(getASTContext(), object, metadata);
+ SetMetadata(getASTContext(), object, meta_data);
}
static void
SetMetadata (clang::ASTContext *ast,
uintptr_t object,
- uint64_t metadata);
+ ClangASTMetadata &meta_data);
- uint64_t GetMetadata (uintptr_t object)
+ ClangASTMetadata *
+ GetMetadata (uintptr_t object)
{
return GetMetadata(getASTContext(), object);
}
- static uint64_t
+ static ClangASTMetadata *
GetMetadata (clang::ASTContext *ast,
uintptr_t object);
@@ -300,7 +304,7 @@ public:
const char *name,
int kind,
lldb::LanguageType language,
- uint64_t metadata = 0);
+ ClangASTMetadata *metadata = NULL);
static clang::FieldDecl *
AddFieldToRecordType (clang::ASTContext *ast,
@@ -459,7 +463,7 @@ public:
clang::DeclContext *decl_ctx,
bool isForwardDecl,
bool isInternal,
- uint64_t metadata = 0);
+ ClangASTMetadata *metadata = NULL);
static clang::FieldDecl *
AddObjCClassIVar (clang::ASTContext *ast,
@@ -498,7 +502,7 @@ public:
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata = 0
+ ClangASTMetadata *metadata = NULL
);
bool
@@ -511,7 +515,7 @@ public:
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata = 0
+ ClangASTMetadata *metadata = NULL
)
{
return ClangASTContext::AddObjCClassProperty (getASTContext(),
diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/include/lldb/Symbol/ClangASTImporter.h
index 3fd1bd8f4c1..587237e90ca 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -83,7 +83,7 @@ public:
void
SetDeclOrigin (const clang::Decl *decl, clang::Decl *original_decl);
- uint64_t
+ ClangASTMetadata *
GetDeclMetadata (const clang::Decl *decl);
//
diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
index 0efe1a6900d..7dc37899497 100644
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -36,19 +36,107 @@
#include <assert.h>
#endif
+#include "lldb/lldb-defines.h"
+#include "lldb/Core/dwarf.h"
+
namespace lldb_private {
+class ClangASTMetadata
+{
+public:
+ ClangASTMetadata () :
+ m_user_id(0),
+ m_union_is_user_id(false),
+ m_union_is_isa_ptr(false),
+ m_has_object_ptr(false),
+ m_is_self (false)
+ {
+ }
+
+ void
+ SetUserID (lldb::user_id_t user_id)
+ {
+ m_user_id = user_id;
+ m_union_is_user_id = true;
+ m_union_is_isa_ptr = false;
+ }
+ lldb::user_id_t GetUserID () const
+ {
+ if (m_union_is_user_id)
+ return m_user_id;
+ else
+ return LLDB_INVALID_UID;
+ }
+
+ void
+ SetISAPtr (uint64_t isa_ptr)
+ {
+ m_isa_ptr = isa_ptr;
+ m_union_is_user_id = false;
+ m_union_is_isa_ptr = true;
+ }
+
+ uint64_t GetISAPtr () const
+ {
+ if (m_union_is_isa_ptr)
+ return m_isa_ptr;
+ else
+ return 0;
+ }
+
+ void SetObjectPtrName(const char *name)
+ {
+ m_has_object_ptr = true;
+ if (strcmp (name, "self") == 0)
+ m_is_self = true;
+ else if (strcmp (name, "this") == 0)
+ m_is_self = false;
+ else
+ m_has_object_ptr = false;
+ }
+
+ const char *GetObjectPtrName() const
+ {
+ if (m_has_object_ptr)
+ {
+ if (m_is_self)
+ return "self";
+ else
+ return "this";
+ }
+ else
+ return NULL;
+ }
+
+ bool HasObjectPtr() const
+ {
+ return m_has_object_ptr;
+ }
+
+private:
+ union
+ {
+ lldb::user_id_t m_user_id;
+ uint64_t m_isa_ptr;
+ };
+ bool m_union_is_user_id : 1,
+ m_union_is_isa_ptr : 1,
+ m_has_object_ptr : 1,
+ m_is_self : 1;
+
+};
+
class ClangExternalASTSourceCommon : public clang::ExternalASTSource
{
public:
ClangExternalASTSourceCommon();
~ClangExternalASTSourceCommon();
-
- virtual uint64_t GetMetadata(uintptr_t object);
- virtual void SetMetadata(uintptr_t object, uint64_t metadata);
+
+ virtual ClangASTMetadata *GetMetadata(uintptr_t object);
+ virtual void SetMetadata(uintptr_t object, ClangASTMetadata &metadata);
virtual bool HasMetadata(uintptr_t object);
private:
- typedef llvm::DenseMap<uintptr_t, uint64_t> MetadataMap;
+ typedef llvm::DenseMap<uintptr_t, ClangASTMetadata> MetadataMap;
MetadataMap m_metadata;
uint64_t m_magic; ///< Because we don't have RTTI, we must take it
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index c128de1dbca..e58aee3e8f9 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -62,6 +62,7 @@ class BroadcasterManager;
class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTImporter;
+class ClangASTMetadata;
class ClangASTSource;
class ClangASTType;
class ClangNamespaceDecl;
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 5a575bd8303..940be042c3d 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -2661,7 +2661,8 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
{
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember
+ | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
var,
err);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
index da6dc2b053a..8aaa9e45294 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
@@ -192,7 +192,9 @@ AppleObjCTypeVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa)
&identifier_info,
NULL);
- m_external_source->SetMetadata((uintptr_t)new_iface_decl, (uint64_t)isa);
+ ClangASTMetadata meta_data;
+ meta_data.SetISAPtr((uint64_t) isa);
+ m_external_source->SetMetadata((uintptr_t)new_iface_decl, meta_data);
new_iface_decl->setHasExternalVisibleStorage();
@@ -488,7 +490,10 @@ AppleObjCTypeVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl)
{
lldb::LogSP log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
- ObjCLanguageRuntime::ObjCISA objc_isa = (ObjCLanguageRuntime::ObjCISA)m_external_source->GetMetadata((uintptr_t)interface_decl);
+ ClangASTMetadata *metadata = m_external_source->GetMetadata((uintptr_t)interface_decl);
+ ObjCLanguageRuntime::ObjCISA objc_isa = 0;
+ if (metadata)
+ objc_isa = metadata->GetISAPtr();
if (!objc_isa)
return false;
@@ -591,10 +596,16 @@ AppleObjCTypeVendor::FindTypes (const ConstString &name,
if (log)
{
ASTDumper dumper(result_iface_type);
+
+ uint64_t isa_value = LLDB_INVALID_ADDRESS;
+ ClangASTMetadata *metadata = m_external_source->GetMetadata((uintptr_t)result_iface_decl);
+ if (metadata)
+ isa_value = metadata->GetISAPtr();
+
log->Printf("AOCTV::FT [%u] Found %s (isa 0x%llx) in the ASTContext",
current_id,
dumper.GetCString(),
- m_external_source->GetMetadata((uintptr_t)result_iface_decl));
+ isa_value);
}
types.push_back(ClangASTType(ast_ctx, result_iface_type.getAsOpaquePtr()));
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c58dd102a9a..9837a12b98b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1482,7 +1482,7 @@ public:
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata = 0
+ const ClangASTMetadata *metadata
) :
m_ast (ast),
m_class_opaque_type (class_opaque_type),
@@ -1491,9 +1491,32 @@ public:
m_ivar_decl (ivar_decl),
m_property_setter_name (property_setter_name),
m_property_getter_name (property_getter_name),
- m_property_attributes (property_attributes),
- m_metadata (metadata)
+ m_property_attributes (property_attributes)
{
+ if (metadata != NULL)
+ {
+ m_metadata_ap.reset(new ClangASTMetadata());
+ *(m_metadata_ap.get()) = *metadata;
+ }
+ }
+
+ DelayedAddObjCClassProperty (const DelayedAddObjCClassProperty &rhs)
+ {
+ m_ast = rhs.m_ast;
+ m_class_opaque_type = rhs.m_class_opaque_type;
+ m_property_name = rhs.m_property_name;
+ m_property_opaque_type = rhs.m_property_opaque_type;
+ m_ivar_decl = rhs.m_ivar_decl;
+ m_property_setter_name = rhs.m_property_setter_name;
+ m_property_getter_name = rhs.m_property_getter_name;
+ m_property_attributes = rhs.m_property_attributes;
+
+ if (rhs.m_metadata_ap.get())
+ {
+ m_metadata_ap.reset (new ClangASTMetadata());
+ *(m_metadata_ap.get()) = *(rhs.m_metadata_ap.get());
+ }
+
}
bool Finalize() const
@@ -1506,7 +1529,7 @@ public:
m_property_setter_name,
m_property_getter_name,
m_property_attributes,
- m_metadata);
+ m_metadata_ap.get());
}
private:
clang::ASTContext *m_ast;
@@ -1517,7 +1540,7 @@ private:
const char *m_property_setter_name;
const char *m_property_getter_name;
uint32_t m_property_attributes;
- uint64_t m_metadata;
+ std::auto_ptr<ClangASTMetadata> m_metadata_ap;
};
size_t
@@ -1740,7 +1763,7 @@ SymbolFileDWARF::ParseChildMembers
accessibility,
bit_size);
- GetClangASTContext().SetMetadata((uintptr_t)field_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)field_decl, MakeUserID(die->GetOffset()));
}
else
{
@@ -1803,6 +1826,8 @@ SymbolFileDWARF::ParseChildMembers
assert (ivar_decl != NULL);
}
+ ClangASTMetadata metadata;
+ metadata.SetUserID (MakeUserID(die->GetOffset()));
delayed_properties.push_back(DelayedAddObjCClassProperty(GetClangASTContext().getASTContext(),
class_clang_type,
prop_name,
@@ -1811,10 +1836,10 @@ SymbolFileDWARF::ParseChildMembers
prop_setter_name,
prop_getter_name,
prop_attributes,
- MakeUserID(die->GetOffset())));
+ &metadata));
if (ivar_decl)
- GetClangASTContext().SetMetadata((uintptr_t)ivar_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)ivar_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -3906,7 +3931,7 @@ SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc,
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);
- GetClangASTContext().SetMetadata((uintptr_t)param_var_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)param_var_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -5552,20 +5577,22 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
clang_type = ast.CreateClassTemplateSpecializationType (class_specialization_decl);
clang_type_was_created = true;
- GetClangASTContext().SetMetadata((uintptr_t)class_template_decl, MakeUserID(die->GetOffset()));
- GetClangASTContext().SetMetadata((uintptr_t)class_specialization_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)class_template_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)class_specialization_decl, MakeUserID(die->GetOffset()));
}
}
if (!clang_type_was_created)
{
clang_type_was_created = true;
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
clang_type = ast.CreateRecordType (decl_ctx,
accessibility,
type_name_cstr,
tag_decl_kind,
class_language,
- MakeUserID(die->GetOffset()));
+ &metadata);
}
}
@@ -5768,6 +5795,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
bool is_artificial = false;
dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET;
+ dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
unsigned type_quals = 0;
clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern
@@ -5821,6 +5849,10 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
abstract_origin_die_offset = form_value.Reference(dwarf_cu);
break;
+ case DW_AT_object_pointer:
+ object_pointer_die_offset = form_value.Reference(dwarf_cu);
+ break;
+
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_address_class:
@@ -5831,7 +5863,6 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
case DW_AT_frame_base:
case DW_AT_high_pc:
case DW_AT_low_pc:
- case DW_AT_object_pointer:
case DW_AT_prototyped:
case DW_AT_pure:
case DW_AT_ranges:
@@ -5851,6 +5882,17 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
}
}
+ std::string object_pointer_name;
+ if (object_pointer_die_offset != DW_INVALID_OFFSET)
+ {
+ // Get the name from the object pointer die
+ StreamString s;
+ if (DWARFDebugInfoEntry::GetName (this, dwarf_cu, object_pointer_die_offset, s))
+ {
+ object_pointer_name.assign(s.GetData());
+ }
+ }
+
DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
clang_type_t return_clang_type = NULL;
@@ -5884,14 +5926,14 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
if (die->HasChildren())
{
bool skip_artificial = true;
- ParseChildParameters (sc,
+ ParseChildParameters (sc,
containing_decl_ctx,
- dwarf_cu,
- die,
+ dwarf_cu,
+ die,
skip_artificial,
is_static,
- type_list,
- function_param_types,
+ type_list,
+ function_param_types,
function_param_decls,
type_quals,
template_param_infos);
@@ -5947,7 +5989,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
if (type_handled)
{
LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
- GetClangASTContext().SetMetadata((uintptr_t)objc_method_decl, MakeUserID(die->GetOffset()));
+ GetClangASTContext().SetMetadataAsUserID ((uintptr_t)objc_method_decl, MakeUserID(die->GetOffset()));
}
}
}
@@ -6079,7 +6121,15 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
type_handled = cxx_method_decl != NULL;
- GetClangASTContext().SetMetadata((uintptr_t)cxx_method_decl, MakeUserID(die->GetOffset()));
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
+
+ if (!object_pointer_name.empty())
+ {
+ metadata.SetObjectPtrName(object_pointer_name.c_str());
+ printf ("Setting object pointer name: %s on method object 0x%ld.\n", object_pointer_name.c_str(), (uintptr_t) cxx_method_decl);
+ }
+ GetClangASTContext().SetMetadata ((uintptr_t)cxx_method_decl, metadata);
}
}
else
@@ -6145,7 +6195,15 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
&function_param_decls.front(),
function_param_decls.size());
- GetClangASTContext().SetMetadata((uintptr_t)function_decl, MakeUserID(die->GetOffset()));
+ ClangASTMetadata metadata;
+ metadata.SetUserID(MakeUserID(die->GetOffset()));
+
+ if (!object_pointer_name.empty())
+ {
+ metadata.SetObjectPtrName(object_pointer_name.c_str());
+ printf ("Setting object pointer name: %s on function object 0x%ld.\n", object_pointer_name.c_str(), (uintptr_t) function_decl);
+ }
+ GetClangASTContext().SetMetadata ((uintptr_t)function_decl, metadata);
}
}
type_sp.reset( new Type (MakeUserID(die->GetOffset()),
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 1e1a0f203f3..5c74dd7686b 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -12,6 +12,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -403,11 +404,13 @@ SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc,
ClangASTContext &ast = GetClangASTContext();
+ ClangASTMetadata metadata;
+ metadata.SetUserID(0xffaaffaaffaaffaall);
lldb::clang_type_t objc_object_type = ast.CreateObjCClass (name.AsCString(),
ast.GetTranslationUnitDecl(),
isForwardDecl,
isInternal,
- 0xffaaffaaffaaffaall);
+ &metadata);
Declaration decl;
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 4ce9aa4c34d..76ec6bc14d0 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -1126,7 +1126,7 @@ ClangASTContext::GetTypeForDecl (ObjCInterfaceDecl *decl)
#pragma mark Structure, Unions, Classes
clang_type_t
-ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type, const char *name, int kind, LanguageType language, uint64_t metadata)
+ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type, const char *name, int kind, LanguageType language, ClangASTMetadata *metadata)
{
ASTContext *ast = getASTContext();
assert (ast != NULL);
@@ -1154,8 +1154,8 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, AccessType access_type
SourceLocation(),
name && name[0] ? &ast->Idents.get(name) : NULL);
- if (decl)
- SetMetadata(ast, (uintptr_t)decl, metadata);
+ if (decl && metadata)
+ SetMetadata(ast, (uintptr_t)decl, *metadata);
if (decl_ctx)
{
@@ -2262,7 +2262,7 @@ ClangASTContext::CreateObjCClass
DeclContext *decl_ctx,
bool isForwardDecl,
bool isInternal,
- uint64_t metadata
+ ClangASTMetadata *metadata
)
{
ASTContext *ast = getASTContext();
@@ -2285,8 +2285,8 @@ ClangASTContext::CreateObjCClass
/*isForwardDecl,*/
isInternal);
- if (decl)
- SetMetadata(ast, (uintptr_t)decl, metadata);
+ if (decl && metadata)
+ SetMetadata(ast, (uintptr_t)decl, *metadata);
return ast->getObjCInterfaceType(decl).getAsOpaquePtr();
}
@@ -2400,7 +2400,7 @@ ClangASTContext::AddObjCClassProperty
const char *property_setter_name,
const char *property_getter_name,
uint32_t property_attributes,
- uint64_t metadata
+ ClangASTMetadata *metadata
)
{
if (class_opaque_type == NULL || property_name == NULL || property_name[0] == '\0')
@@ -2447,7 +2447,8 @@ ClangASTContext::AddObjCClassProperty
if (property_decl)
{
- SetMetadata(ast, (uintptr_t)property_decl, metadata);
+ if (metadata)
+ SetMetadata(ast, (uintptr_t)property_decl, *metadata);
class_interface_decl->addDecl (property_decl);
@@ -2526,8 +2527,8 @@ ClangASTContext::AddObjCClassProperty
impControl,
HasRelatedResultType);
- if (getter)
- SetMetadata(ast, (uintptr_t)getter, metadata);
+ if (getter && metadata)
+ SetMetadata(ast, (uintptr_t)getter, *metadata);
getter->setMethodParams(*ast, ArrayRef<ParmVarDecl*>(), ArrayRef<SourceLocation>());
@@ -2561,8 +2562,8 @@ ClangASTContext::AddObjCClassProperty
impControl,
HasRelatedResultType);
- if (setter)
- SetMetadata(ast, (uintptr_t)setter, metadata);
+ if (setter && metadata)
+ SetMetadata(ast, (uintptr_t)setter, *metadata);
llvm::SmallVector<ParmVarDecl *, 1> params;
@@ -6400,9 +6401,18 @@ ClangASTContext::GetCompleteDecl (clang::ASTContext *ast,
}
void
+ClangASTContext::SetMetadataAsUserID (uintptr_t object,
+ user_id_t user_id)
+{
+ ClangASTMetadata meta_data;
+ meta_data.SetUserID (user_id);
+ SetMetadata (object, meta_data);
+}
+
+void
ClangASTContext::SetMetadata (clang::ASTContext *ast,
uintptr_t object,
- uint64_t metadata)
+ ClangASTMetadata &metadata)
{
ClangExternalASTSourceCommon *external_source =
static_cast<ClangExternalASTSourceCommon*>(ast->getExternalSource());
@@ -6411,7 +6421,7 @@ ClangASTContext::SetMetadata (clang::ASTContext *ast,
external_source->SetMetadata(object, metadata);
}
-uint64_t
+ClangASTMetadata *
ClangASTContext::GetMetadata (clang::ASTContext *ast,
uintptr_t object)
{
@@ -6421,7 +6431,7 @@ ClangASTContext::GetMetadata (clang::ASTContext *ast,
if (external_source && external_source->HasMetadata(object))
return external_source->GetMetadata(object);
else
- return 0;
+ return NULL;
}
clang::DeclContext *
@@ -6478,6 +6488,17 @@ ClangASTContext::GetClassMethodInfoForDeclContext (clang::DeclContext *decl_ctx,
language = eLanguageTypeObjC;
return true;
}
+ else if (clang::FunctionDecl *function_decl = llvm::dyn_cast<clang::FunctionDecl>(decl_ctx))
+ {
+ ClangASTMetadata *metadata = GetMetadata (&decl_ctx->getParentASTContext(), (uintptr_t) function_decl);
+ if (metadata && metadata->HasObjectPtr())
+ {
+ language_object_name.SetCString (metadata->GetObjectPtrName());
+ language = eLanguageTypeObjC;
+ is_instance_method = true;
+ }
+ return true;
+ }
}
return false;
}
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index b12128467de..bd669fccf21 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -60,15 +60,20 @@ ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast,
if (log)
{
+ lldb::user_id_t user_id;
+ ClangASTMetadata *metadata = GetDeclMetadata(decl);
+ if (metadata)
+ user_id = metadata->GetUserID();
+
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s '%s', metadata 0x%llx",
decl->getDeclKindName(),
named_decl->getNameAsString().c_str(),
- GetDeclMetadata(decl));
+ user_id);
else
log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, metadata 0x%llx",
decl->getDeclKindName(),
- GetDeclMetadata(decl));
+ user_id);
}
}
@@ -243,7 +248,7 @@ ClangASTImporter::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface
return true;
}
-uint64_t
+ClangASTMetadata *
ClangASTImporter::GetDeclMetadata (const clang::Decl *decl)
{
DeclOrigin decl_origin = GetDeclOrigin(decl);
@@ -450,6 +455,11 @@ clang::Decl
if (log)
{
+ lldb::user_id_t user_id;
+ ClangASTMetadata *metadata = m_master.GetDeclMetadata(from);
+ if (metadata)
+ user_id = metadata->GetUserID();
+
if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from))
{
std::string name_string;
@@ -462,7 +472,7 @@ clang::Decl
to,
name_string.c_str(),
from,
- m_master.GetDeclMetadata(from));
+ user_id);
}
else
{
@@ -470,7 +480,7 @@ clang::Decl
from->getDeclKindName(),
to,
from,
- m_master.GetDeclMetadata(from));
+ user_id);
}
}
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
index 85e1dc8e273..0e00e408166 100644
--- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -27,14 +27,19 @@ ClangExternalASTSourceCommon::~ClangExternalASTSourceCommon()
g_TotalSizeOfMetadata -= m_metadata.size();
}
-uint64_t ClangExternalASTSourceCommon::GetMetadata (uintptr_t object)
+ClangASTMetadata *
+ClangExternalASTSourceCommon::GetMetadata (uintptr_t object)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
- return m_metadata[object];
+ if (HasMetadata (object))
+ return &m_metadata[object];
+ else
+ return NULL;
}
-void ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, uint64_t metadata)
+void
+ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, ClangASTMetadata &metadata)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
@@ -44,7 +49,8 @@ void ClangExternalASTSourceCommon::SetMetadata (uintptr_t object, uint64_t metad
g_TotalSizeOfMetadata += (new_size - orig_size);
}
-bool ClangExternalASTSourceCommon::HasMetadata (uintptr_t object)
+bool
+ClangExternalASTSourceCommon::HasMetadata (uintptr_t object)
{
assert (m_magic == ClangExternalASTSourceCommon_MAGIC);
OpenPOWER on IntegriCloud