summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ClangASTSource.cpp2
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp162
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp2
3 files changed, 135 insertions, 31 deletions
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index 854fcc880d9..f68e07c6b49 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -105,7 +105,7 @@ ClangASTSource::FindExternalVisibleDeclsByName
// printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name);
llvm::SmallVector<NamedDecl*, 4> name_decls;
NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx);
- m_decl_map.GetDecls(name_search_context, const_decl_name);
+ m_decl_map.FindExternalVisibleDecls(name_search_context, const_decl_name);
DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls));
// --g_depth;
m_active_lookups.erase (uniqued_const_decl_name);
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index e08985a27de..42484f1242a 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -32,6 +32,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/Variable.h"
@@ -2055,16 +2056,10 @@ ClangExpressionDeclMap::FindGlobalVariable
// Interface for ClangASTSource
-void
-ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString &name)
+void
+ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, const ConstString &name)
{
- assert (m_struct_vars.get());
- assert (m_parser_vars.get());
-
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- if (log)
- log->Printf("Hunting for a definition for '%s'", name.GetCString());
if (m_parser_vars->m_ignore_lookups)
{
@@ -2073,6 +2068,65 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
return;
}
+ if (log)
+ {
+ if (!context.m_decl_context)
+ log->Printf("FindExternalVisibleDecls for '%s' in a NULL DeclContext", name.GetCString());
+ else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context))
+ log->Printf("FindExternalVisibleDecls for '%s' in '%s'", name.GetCString(), context_named_decl->getNameAsString().c_str());
+ else
+ log->Printf("FindExternalVisibleDecls for '%s' in a '%s'", name.GetCString(), context.m_decl_context->getDeclKindName());
+ }
+
+ if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
+ {
+ ClangASTImporter::NamespaceMapSP namespace_map = m_parser_vars->m_ast_importer->GetNamespaceMap(namespace_context);
+
+ for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end();
+ i != e;
+ ++i)
+ {
+ if (log)
+ log->Printf(" Searching namespace '%s' in file '%s'",
+ i->second.GetNamespaceDecl()->getNameAsString().c_str(),
+ i->first->GetFileSpec().GetFilename().GetCString());
+
+ //FindExternalVisibleDecls(context,
+ // i->first,
+ // i->second,
+ // name);
+ }
+ }
+ else if (!isa<TranslationUnitDecl>(context.m_decl_context))
+ {
+ // we shouldn't be getting FindExternalVisibleDecls calls for these
+ return;
+ }
+ else
+ {
+ ClangNamespaceDecl namespace_decl;
+
+ if (log)
+ log->Printf(" Searching without a namespace");
+
+ FindExternalVisibleDecls(context,
+ lldb::ModuleSP(),
+ namespace_decl,
+ name);
+ }
+}
+
+void
+ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
+ lldb::ModuleSP module,
+ ClangNamespaceDecl &decl,
+ const ConstString &name)
+{
+ assert (m_struct_vars.get());
+ assert (m_parser_vars.get());
+
+ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
do
{
if (isa<TranslationUnitDecl>(context.m_decl_context))
@@ -2153,10 +2207,10 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
if (frame)
{
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
- eNoDynamicValues,
- StackFrame::eExpressionPathOptionCheckPtrVsMember,
- var,
- err);
+ eNoDynamicValues,
+ StackFrame::eExpressionPathOptionCheckPtrVsMember,
+ var,
+ err);
// If we found a variable in scope, no need to pull up function names
if (err.Success() && var != NULL)
@@ -2249,25 +2303,53 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
}
}
- ClangNamespaceDecl namespace_decl (m_parser_vars->m_sym_ctx.FindNamespace(name));
+ ModuleList &images = m_parser_vars->m_sym_ctx.target_sp->GetImages();
+
+ ClangASTImporter::NamespaceMapSP namespace_decls(new ClangASTImporter::NamespaceMap);
- if (namespace_decl)
+ for (uint32_t i = 0, e = images.GetSize();
+ i != e;
+ ++i)
{
- if (log)
- {
- std::string s;
- llvm::raw_string_ostream os(s);
- namespace_decl.GetNamespaceDecl()->print(os);
- os.flush();
+ ModuleSP image = images.GetModuleAtIndex(i);
+
+ if (!image)
+ continue;
+
+ ClangNamespaceDecl namespace_decl;
+
+ SymbolVendor *symbol_vendor = image->GetSymbolVendor();
+
+ if (!symbol_vendor)
+ continue;
+
+ SymbolContext null_sc;
+
+ namespace_decl = symbol_vendor->FindNamespace(null_sc, name);
+
+ if (namespace_decl)
+ {
+ (*namespace_decls)[image] = namespace_decl;
- log->Printf("Added namespace decl:");
- log->Printf("%s", s.c_str());
+ if (log)
+ {
+ std::string s;
+ llvm::raw_string_ostream os(s);
+ namespace_decl.GetNamespaceDecl()->print(os);
+ os.flush();
+
+ log->Printf("Found namespace %s in file %s", s.c_str(), image->GetFileSpec().GetFilename().GetCString());
+ }
}
+ }
+
+ if (!namespace_decls->empty())
+ {
+ NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decls);
- NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl);
if (clang_namespace_decl)
- clang_namespace_decl->setHasExternalLexicalStorage();
- }
+ clang_namespace_decl->setHasExternalVisibleStorage();
+ }
}
else
{
@@ -2485,7 +2567,20 @@ ClangExpressionDeclMap::FindExternalLexicalDecls (const DeclContext *decl_contex
ASTContext *ast_context = &context_decl->getASTContext();
if (log)
- log->Printf("Finding lexical decls in a '%s' with %s predicate", context_decl->getDeclKindName(), (predicate ? "non-null" : "null"));
+ {
+ if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
+ log->Printf("FindExternalLexicalDecls in '%s' (a %s) with %s predicate",
+ context_named_decl->getNameAsString().c_str(),
+ context_decl->getDeclKindName(),
+ (predicate ? "non-null" : "null"));
+ else if(context_decl)
+ log->Printf("FindExternalLexicalDecls in a %s with %s predicate",
+ context_decl->getDeclKindName(),
+ (predicate ? "non-null" : "null"));
+ else
+ log->Printf("FindExternalLexicalDecls in a NULL context with %s predicate",
+ (predicate ? "non-null" : "null"));
+ }
Decl *original_decl = NULL;
ASTContext *original_ctx = NULL;
@@ -2933,15 +3028,24 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
}
NamespaceDecl *
-ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, const ClangNamespaceDecl &namespace_decl)
+ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
{
+ if (namespace_decls.empty())
+ return NULL;
+
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
assert (m_parser_vars.get());
+ const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
+
Decl *copied_decl = m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(namespace_decl.GetASTContext(),
- namespace_decl.GetNamespaceDecl());
-
+ namespace_decl.GetNamespaceDecl());
+
+ NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
+
+ m_parser_vars->GetASTImporter(context.GetASTContext())->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
+
return dyn_cast<NamespaceDecl>(copied_decl);
}
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 17cc5a84c0d..3156a3389a9 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -556,7 +556,7 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
.setOptLevel(CodeGenOpt::Less)
.setAllocateGVsWithCode(true)
.setCodeModel(CodeModel::Small)
- .setUseMCJIT(true);
+ .setUseMCJIT(true);
m_execution_engine.reset(builder.create());
#endif
OpenPOWER on IntegriCloud