summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ASTResultSynthesizer.cpp20
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp138
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp10
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp3
4 files changed, 132 insertions, 39 deletions
diff --git a/lldb/source/Expression/ASTResultSynthesizer.cpp b/lldb/source/Expression/ASTResultSynthesizer.cpp
index f28f8f1b735..ff3b2f4814d 100644
--- a/lldb/source/Expression/ASTResultSynthesizer.cpp
+++ b/lldb/source/Expression/ASTResultSynthesizer.cpp
@@ -22,6 +22,8 @@
#include "lldb/Expression/ClangPersistentVariables.h"
#include "lldb/Expression/ASTResultSynthesizer.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTImporter.h"
+#include "lldb/Target/Target.h"
using namespace llvm;
using namespace clang;
@@ -29,13 +31,11 @@ using namespace lldb_private;
ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough,
TypeFromUser desired_type,
- ASTContext &scratch_ast_context,
- ClangPersistentVariables &persistent_vars) :
+ Target &target) :
m_ast_context (NULL),
m_passthrough (passthrough),
m_passthrough_sema (NULL),
- m_scratch_ast_context (scratch_ast_context),
- m_persistent_vars (persistent_vars),
+ m_target (target),
m_sema (NULL),
m_desired_type (desired_type)
{
@@ -442,14 +442,12 @@ ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D)
if (log)
log->Printf ("Recording persistent type %s\n", name_cs.GetCString());
- Decl *D_scratch = ClangASTContext::CopyDecl(&m_scratch_ast_context,
- m_ast_context,
- D);
+ Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(m_target.GetScratchClangASTContext()->getASTContext(),
+ m_ast_context,
+ D);
- TypeDecl *TD_scratch = dyn_cast<TypeDecl>(D_scratch);
-
- if (TD_scratch)
- m_persistent_vars.RegisterPersistentType(name_cs, TD_scratch);
+ if (TypeDecl *TypeDecl_scratch = dyn_cast<TypeDecl>(D_scratch))
+ m_target.GetPersistentVariables().RegisterPersistentType(name_cs, TypeDecl_scratch);
}
void
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 0eca0a455f8..19baef0b061 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -463,29 +463,11 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
SymbolContext null_sc;
if (module_sp && namespace_decl)
- {
module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types);
- }
else if(name != id_name && name != Class_name)
- {
- m_target->GetImages().FindTypes (null_sc, name, true, 1, types);
-
- if (!types.GetSize())
- {
- lldb::ProcessSP process = m_target->GetProcessSP();
-
- if (process && process->GetObjCLanguageRuntime())
- {
- SymbolVendor *objc_symbol_vendor = process->GetObjCLanguageRuntime()->GetSymbolVendor();
-
- objc_symbol_vendor->FindTypes(null_sc, name, NULL, true, 1, types);
- }
- }
- }
+ m_target->GetImages().FindTypes(null_sc, name, true, 1, types);
else
- {
break;
- }
if (types.GetSize())
{
@@ -501,13 +483,15 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
(name_string ? name_string : "<anonymous>"));
}
+
void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType());
-
+
if (!copied_type)
{
if (log)
- log->Printf("ClangExpressionDeclMap::BuildIntegerVariable - Couldn't export the type for a constant integer result");
-
+ log->Printf(" CAS::FEVD[%u] - Couldn't export the type for a constant integer result",
+ current_id);
+
break;
}
@@ -534,6 +518,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
return;
StreamString ss;
+
if (decl_name.isObjCZeroArgSelector())
{
ss.Printf("%s", decl_name.getAsString().c_str());
@@ -565,6 +550,90 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
interface_decl->getNameAsString().c_str(),
selector_name.AsCString());
+ ClangASTImporter::ObjCInterfaceMapSP interface_map = m_ast_importer->GetObjCInterfaceMap(interface_decl);
+
+ if (interface_map)
+ {
+ for (ClangASTImporter::ObjCInterfaceMap::iterator i = interface_map->begin(), e = interface_map->end();
+ i != e;
+ ++i)
+ {
+ lldb::clang_type_t backing_type = i->GetOpaqueQualType();
+
+ if (!backing_type)
+ continue;
+
+ QualType backing_qual_type = QualType::getFromOpaquePtr(backing_type);
+
+ const ObjCInterfaceType *backing_interface_type = dyn_cast<ObjCInterfaceType>(backing_qual_type.getTypePtr());
+
+ if (!backing_interface_type)
+ continue;
+
+ const ObjCInterfaceDecl *backing_interface_decl = backing_interface_type->getDecl();
+
+ if (!backing_interface_decl)
+ continue;
+
+ if (backing_interface_decl->decls_begin() == backing_interface_decl->decls_end())
+ continue; // don't waste time creating a DeclarationName here
+
+ clang::ASTContext &backing_ast_context = backing_interface_decl->getASTContext();
+
+ llvm::SmallVector<clang::IdentifierInfo *, 3> selector_components;
+
+ if (decl_name.isObjCZeroArgSelector())
+ {
+ selector_components.push_back (&backing_ast_context.Idents.get(decl_name.getAsString().c_str()));
+ }
+ else if (decl_name.isObjCOneArgSelector())
+ {
+ selector_components.push_back (&backing_ast_context.Idents.get(decl_name.getAsString().c_str()));
+ }
+ else
+ {
+ clang::Selector sel = decl_name.getObjCSelector();
+
+ for (unsigned i = 0, e = sel.getNumArgs();
+ i != e;
+ ++i)
+ {
+ llvm::StringRef r = sel.getNameForSlot(i);
+
+ selector_components.push_back (&backing_ast_context.Idents.get(r.str().c_str()));
+ }
+ }
+
+ Selector backing_selector = backing_interface_decl->getASTContext().Selectors.getSelector(selector_components.size(), selector_components.data());
+ DeclarationName backing_decl_name = DeclarationName(backing_selector);
+
+ DeclContext::lookup_const_result lookup_result = backing_interface_decl->lookup(backing_decl_name);
+
+ if (lookup_result.first == lookup_result.second)
+ continue;
+
+ ObjCMethodDecl *method_decl = dyn_cast<ObjCMethodDecl>(*lookup_result.first);
+
+ if (!method_decl)
+ continue;
+
+ Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &backing_ast_context, *lookup_result.first);
+
+ ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl> (copied_decl);
+
+ if (!copied_method_decl)
+ continue;
+
+ if (log)
+ {
+ ASTDumper dumper((Decl*)copied_method_decl);
+ log->Printf(" CAS::FOMD[%d] found (in symbols) %s", current_id, dumper.GetCString());
+ }
+
+ context.AddNamedDecl(copied_method_decl);
+ }
+ }
+
SymbolContextList sc_list;
const bool include_symbols = false;
@@ -614,7 +683,7 @@ ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
if (log)
{
ASTDumper dumper((Decl*)copied_method_decl);
- log->Printf(" CAS::FOMD[%d] found %s", current_id, dumper.GetCString());
+ log->Printf(" CAS::FOMD[%d] found (in debug info) %s", current_id, dumper.GetCString());
}
context.AddNamedDecl(copied_method_decl);
@@ -777,6 +846,29 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
}
}
+void
+ClangASTSource::CompleteObjCInterfaceMap (ClangASTImporter::ObjCInterfaceMapSP &objc_interface_map,
+ const ConstString &name) const
+{
+ SymbolContext null_sc;
+
+ TypeList types;
+
+ m_target->GetImages().FindTypes(null_sc, name, true, UINT32_MAX, types);
+
+ for (uint32_t i = 0, e = types.GetSize();
+ i != e;
+ ++i)
+ {
+ lldb::TypeSP mapped_type_sp = types.GetTypeAtIndex(i);
+
+ if (!mapped_type_sp || !mapped_type_sp->GetClangFullType())
+ continue;
+
+ objc_interface_map->push_back (ClangASTType(mapped_type_sp->GetClangAST(), mapped_type_sp->GetClangFullType()));
+ }
+}
+
NamespaceDecl *
ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
{
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 6fbec8f80a3..d879f19985a 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -895,8 +895,12 @@ ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
return err.Success();
}
case Value::eValueTypeHostAddress:
- memcpy ((void *)value.GetScalar().ULongLong(), data, length);
- return true;
+ {
+ if (value.GetScalar().ULongLong() == 0 || data == NULL)
+ return false;
+ memcpy ((void *)value.GetScalar().ULongLong(), data, length);
+ return true;
+ }
case Value::eValueTypeScalar:
return false;
}
@@ -2474,7 +2478,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!ptype_type_decl)
break;
- Decl *parser_ptype_decl = ClangASTContext::CopyDecl(m_ast_context, scratch_ast_context, ptype_type_decl);
+ Decl *parser_ptype_decl = m_ast_importer->CopyDecl(m_ast_context, scratch_ast_context, ptype_type_decl);
if (!parser_ptype_decl)
break;
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index 4ae34a38d58..04d5c32d1f2 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -92,8 +92,7 @@ ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
if (!m_result_synthesizer.get())
m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
m_desired_type,
- *m_target->GetScratchClangASTContext()->getASTContext(),
- m_target->GetPersistentVariables()));
+ *m_target));
return m_result_synthesizer.get();
}
OpenPOWER on IntegriCloud