forked from OSchip/llvm-project
Cloned FindExternalVisibleDecls from
ClangExpressionDeclMap to ClangASTSource, and moved all general type and namespace lookups into ClangASTSource. Now ClangASTSource is ready to complete types given nothing more than a target and an AST context. llvm-svn: 143292
This commit is contained in:
parent
932de2bc86
commit
fb3e4306af
|
@ -195,7 +195,7 @@ public:
|
|||
bool GetImportInProgress () { return m_import_in_progress; }
|
||||
|
||||
void SetLookupsEnabled (bool lookups_enabled) { m_lookups_enabled = lookups_enabled; }
|
||||
bool GetLookupsEnabled () { return m_lookups_enabled; }
|
||||
bool GetLookupsEnabled () { return m_lookups_enabled; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
/// @class ClangASTSourceProxy ClangASTSource.h "lldb/Expression/ClangASTSource.h"
|
||||
|
@ -253,6 +253,54 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
//------------------------------------------------------------------
|
||||
/// Find all entities matching a given name in a given module,
|
||||
/// using a NameSearchContext to make Decls for them.
|
||||
///
|
||||
/// @param[in] context
|
||||
/// The NameSearchContext that can construct Decls for this name.
|
||||
///
|
||||
/// @param[in] module
|
||||
/// If non-NULL, the module to query.
|
||||
///
|
||||
/// @param[in] namespace_decl
|
||||
/// If valid and module is non-NULL, the parent namespace.
|
||||
///
|
||||
/// @param[in] current_id
|
||||
/// The ID for the current FindExternalVisibleDecls invocation,
|
||||
/// for logging purposes.
|
||||
///
|
||||
/// @return
|
||||
/// True on success; false otherwise.
|
||||
//------------------------------------------------------------------
|
||||
void
|
||||
FindExternalVisibleDecls (NameSearchContext &context,
|
||||
lldb::ModuleSP module,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
unsigned int current_id);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// A wrapper for ClangASTContext::CopyType that sets a flag that
|
||||
/// indicates that we should not respond to queries during import.
|
||||
///
|
||||
/// @param[in] dest_context
|
||||
/// The target AST context, typically the parser's AST context.
|
||||
///
|
||||
/// @param[in] source_context
|
||||
/// The source AST context, typically the AST context of whatever
|
||||
/// symbol file the type was found in.
|
||||
///
|
||||
/// @param[in] clang_type
|
||||
/// The source type.
|
||||
///
|
||||
/// @return
|
||||
/// The imported type.
|
||||
//------------------------------------------------------------------
|
||||
void *
|
||||
GuardedCopyType (clang::ASTContext *dest_context,
|
||||
clang::ASTContext *source_context,
|
||||
void *clang_type);
|
||||
|
||||
friend struct NameSearchContext;
|
||||
|
||||
bool m_import_in_progress;
|
||||
|
|
|
@ -621,6 +621,38 @@ public:
|
|||
//------------------------------------------------------------------
|
||||
void
|
||||
FindExternalVisibleDecls (NameSearchContext &context);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Find all entities matching a given name in a given module/namespace,
|
||||
/// using a NameSearchContext to make Decls for them.
|
||||
///
|
||||
/// @param[in] context
|
||||
/// The NameSearchContext that can construct Decls for this name.
|
||||
///
|
||||
/// @param[in] module
|
||||
/// If non-NULL, the module to query.
|
||||
///
|
||||
/// @param[in] namespace_decl
|
||||
/// If valid and module is non-NULL, the parent namespace.
|
||||
///
|
||||
/// @param[in] name
|
||||
/// The name as a plain C string. The NameSearchContext contains
|
||||
/// a DeclarationName for the name so at first the name may seem
|
||||
/// redundant, but ClangExpressionDeclMap operates in RTTI land so
|
||||
/// it can't access DeclarationName.
|
||||
///
|
||||
/// @param[in] current_id
|
||||
/// The ID for the current FindExternalVisibleDecls invocation,
|
||||
/// for logging purposes.
|
||||
///
|
||||
/// @return
|
||||
/// True on success; false otherwise.
|
||||
//------------------------------------------------------------------
|
||||
void
|
||||
FindExternalVisibleDecls (NameSearchContext &context,
|
||||
lldb::ModuleSP module,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
unsigned int current_id);
|
||||
private:
|
||||
ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser.
|
||||
ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct.
|
||||
|
@ -637,8 +669,7 @@ private:
|
|||
m_exe_ctx(NULL),
|
||||
m_sym_ctx(),
|
||||
m_persistent_vars(NULL),
|
||||
m_enable_lookups(false),
|
||||
m_ignore_lookups(false)
|
||||
m_enable_lookups(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -656,7 +687,6 @@ private:
|
|||
SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables and types.
|
||||
ClangPersistentVariables *m_persistent_vars; ///< The persistent variables for the process.
|
||||
bool m_enable_lookups; ///< Set to true during parsing if we have found the first "$__lldb" name.
|
||||
bool m_ignore_lookups; ///< True during an import when we should be ignoring type lookups.
|
||||
std::auto_ptr<ClangASTImporter> m_ast_importer; ///< The importer used to import types on the parser's behalf.
|
||||
TargetInfo m_target_info; ///< Basic information about the target.
|
||||
private:
|
||||
|
@ -764,39 +794,6 @@ private:
|
|||
m_material_vars.reset();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// [Used by ClangASTSource] Find all entities matching a given name,
|
||||
/// using a NameSearchContext to make Decls for them.
|
||||
///
|
||||
/// @param[in] context
|
||||
/// The NameSearchContext that can construct Decls for this name.
|
||||
///
|
||||
/// @param[in] module
|
||||
/// If non-NULL, the module to query.
|
||||
///
|
||||
/// @param[in] namespace_decl
|
||||
/// If valid and module is non-NULL, the parent namespace.
|
||||
///
|
||||
/// @param[in] name
|
||||
/// The name as a plain C string. The NameSearchContext contains
|
||||
/// a DeclarationName for the name so at first the name may seem
|
||||
/// redundant, but ClangExpressionDeclMap operates in RTTI land so
|
||||
/// it can't access DeclarationName.
|
||||
///
|
||||
/// @param[in] current_id
|
||||
/// The ID for the current FindExternalVisibleDecls invocation,
|
||||
/// for logging purposes.
|
||||
///
|
||||
/// @return
|
||||
/// True on success; false otherwise.
|
||||
//------------------------------------------------------------------
|
||||
void
|
||||
FindExternalVisibleDecls (NameSearchContext &context,
|
||||
lldb::ModuleSP module,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
const ConstString &name,
|
||||
unsigned int current_id);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Given a stack frame, find a variable that matches the given name and
|
||||
/// type. We need this for expression re-use; we may not always get the
|
||||
|
@ -1167,28 +1164,6 @@ private:
|
|||
const RegisterInfo ®_info,
|
||||
lldb::addr_t addr,
|
||||
Error &err);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// A wrapper for ClangASTContext::CopyType that sets a flag that
|
||||
/// indicates that we should not respond to queries during import.
|
||||
///
|
||||
/// @param[in] dest_context
|
||||
/// The target AST context, typically the parser's AST context.
|
||||
///
|
||||
/// @param[in] source_context
|
||||
/// The source AST context, typically the AST context of whatever
|
||||
/// symbol file the type was found in.
|
||||
///
|
||||
/// @param[in] clang_type
|
||||
/// The source type.
|
||||
///
|
||||
/// @return
|
||||
/// The imported type.
|
||||
//------------------------------------------------------------------
|
||||
void *
|
||||
GuardedCopyType (clang::ASTContext *dest_context,
|
||||
clang::ASTContext *source_context,
|
||||
void *clang_type);
|
||||
};
|
||||
|
||||
} // namespace lldb_private
|
||||
|
|
|
@ -121,11 +121,6 @@ ClangASTSource::FindExternalVisibleDeclsByName
|
|||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::CompleteType (TagDecl *tag_decl)
|
||||
{
|
||||
|
@ -257,6 +252,211 @@ ClangASTSource::FindExternalLexicalDecls (const DeclContext *decl_context,
|
|||
return ELR_AlreadyLoaded;
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context)
|
||||
{
|
||||
assert (m_ast_context);
|
||||
|
||||
const ConstString name(context.m_decl_name.getAsString().c_str());
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
static unsigned int invocation_id = 0;
|
||||
unsigned int current_id = invocation_id++;
|
||||
|
||||
if (log)
|
||||
{
|
||||
if (!context.m_decl_context)
|
||||
log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a NULL DeclContext", current_id, name.GetCString());
|
||||
else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context))
|
||||
log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in '%s'", current_id, name.GetCString(), context_named_decl->getNameAsString().c_str());
|
||||
else
|
||||
log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a '%s'", current_id, name.GetCString(), context.m_decl_context->getDeclKindName());
|
||||
}
|
||||
|
||||
context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap);
|
||||
|
||||
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
|
||||
{
|
||||
ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
|
||||
|
||||
if (log && log->GetVerbose())
|
||||
log->Printf(" CAS::FEVD[%u] Inspecting namespace map %p (%d entries)",
|
||||
current_id,
|
||||
namespace_map.get(),
|
||||
(int)namespace_map->size());
|
||||
|
||||
if (!namespace_map)
|
||||
return;
|
||||
|
||||
for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end();
|
||||
i != e;
|
||||
++i)
|
||||
{
|
||||
if (log)
|
||||
log->Printf(" CAS::FEVD[%u] Searching namespace %s in module %s",
|
||||
current_id,
|
||||
i->second.GetNamespaceDecl()->getNameAsString().c_str(),
|
||||
i->first->GetFileSpec().GetFilename().GetCString());
|
||||
|
||||
FindExternalVisibleDecls(context,
|
||||
i->first,
|
||||
i->second,
|
||||
current_id);
|
||||
}
|
||||
}
|
||||
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(" CAS::FEVD[%u] Searching the root namespace", current_id);
|
||||
|
||||
FindExternalVisibleDecls(context,
|
||||
lldb::ModuleSP(),
|
||||
namespace_decl,
|
||||
current_id);
|
||||
}
|
||||
|
||||
if (!context.m_namespace_map->empty())
|
||||
{
|
||||
if (log && log->GetVerbose())
|
||||
log->Printf(" CAS::FEVD[%u] Registering namespace map %p (%d entries)",
|
||||
current_id,
|
||||
context.m_namespace_map.get(),
|
||||
(int)context.m_namespace_map->size());
|
||||
|
||||
NamespaceDecl *clang_namespace_decl = AddNamespace(context, context.m_namespace_map);
|
||||
|
||||
if (clang_namespace_decl)
|
||||
clang_namespace_decl->setHasExternalVisibleStorage();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
||||
lldb::ModuleSP module_sp,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
unsigned int current_id)
|
||||
{
|
||||
assert (m_ast_context);
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
SymbolContextList sc_list;
|
||||
|
||||
const ConstString name(context.m_decl_name.getAsString().c_str());
|
||||
|
||||
const char *name_unique_cstr = name.GetCString();
|
||||
|
||||
if (name_unique_cstr == NULL)
|
||||
return;
|
||||
|
||||
// The ClangASTSource is not responsible for finding $-names.
|
||||
if (name_unique_cstr[0] == '$')
|
||||
return;
|
||||
|
||||
if (module_sp && namespace_decl)
|
||||
{
|
||||
ClangNamespaceDecl found_namespace_decl;
|
||||
|
||||
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
|
||||
|
||||
if (symbol_vendor)
|
||||
{
|
||||
SymbolContext null_sc;
|
||||
|
||||
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
||||
|
||||
if (found_namespace_decl)
|
||||
{
|
||||
context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
|
||||
|
||||
if (log)
|
||||
log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
module_sp->GetFileSpec().GetFilename().GetCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleList &images = m_target->GetImages();
|
||||
|
||||
for (uint32_t i = 0, e = images.GetSize();
|
||||
i != e;
|
||||
++i)
|
||||
{
|
||||
lldb::ModuleSP image = images.GetModuleAtIndex(i);
|
||||
|
||||
if (!image)
|
||||
continue;
|
||||
|
||||
ClangNamespaceDecl found_namespace_decl;
|
||||
|
||||
SymbolVendor *symbol_vendor = image->GetSymbolVendor();
|
||||
|
||||
if (!symbol_vendor)
|
||||
continue;
|
||||
|
||||
SymbolContext null_sc;
|
||||
|
||||
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
||||
|
||||
if (found_namespace_decl)
|
||||
{
|
||||
context.m_namespace_map->push_back(std::pair<lldb::ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
|
||||
|
||||
if (log)
|
||||
log->Printf(" CAS::FEVD[%u] Found namespace %s in module %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
image->GetFileSpec().GetFilename().GetCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ConstString id_name("id");
|
||||
|
||||
do
|
||||
{
|
||||
TypeList types;
|
||||
SymbolContext null_sc;
|
||||
|
||||
if (module_sp && namespace_decl)
|
||||
module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types);
|
||||
else if(name != id_name)
|
||||
m_target->GetImages().FindTypes (null_sc, name, true, 1, types);
|
||||
else
|
||||
break;
|
||||
|
||||
if (types.GetSize())
|
||||
{
|
||||
lldb::TypeSP type_sp = types.GetTypeAtIndex(0);
|
||||
|
||||
if (log)
|
||||
{
|
||||
const char *name_string = type_sp->GetName().GetCString();
|
||||
|
||||
log->Printf(" CAS::FEVD[%u] Matching type found for \"%s\": %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
(name_string ? name_string : "<anonymous>"));
|
||||
}
|
||||
|
||||
void *copied_type = GuardedCopyType(m_ast_context, type_sp->GetClangAST(), type_sp->GetClangFullType());
|
||||
|
||||
context.AddTypeDecl(copied_type);
|
||||
}
|
||||
} while(0);
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map,
|
||||
const ConstString &name,
|
||||
|
@ -371,6 +571,22 @@ ClangASTSource::AddNamespace (NameSearchContext &context, ClangASTImporter::Name
|
|||
return dyn_cast<NamespaceDecl>(copied_decl);
|
||||
}
|
||||
|
||||
void *
|
||||
ClangASTSource::GuardedCopyType (ASTContext *dest_context,
|
||||
ASTContext *source_context,
|
||||
void *clang_type)
|
||||
{
|
||||
SetImportInProgress(true);
|
||||
|
||||
QualType ret_qual_type = m_ast_importer->CopyType (source_context, QualType::getFromOpaquePtr(clang_type));
|
||||
|
||||
void *ret = ret_qual_type.getAsOpaquePtr();
|
||||
|
||||
SetImportInProgress(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
clang::NamedDecl *
|
||||
NameSearchContext::AddVarDecl(void *type)
|
||||
{
|
||||
|
|
|
@ -2140,7 +2140,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
|
|||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (m_parser_vars->m_ignore_lookups)
|
||||
if (GetImportInProgress())
|
||||
{
|
||||
if (log && log->GetVerbose())
|
||||
log->Printf("Ignoring a query during an import");
|
||||
|
@ -2153,21 +2153,19 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
|
|||
if (log)
|
||||
{
|
||||
if (!context.m_decl_context)
|
||||
log->Printf("FindExternalVisibleDecls[%u] for '%s' in a NULL DeclContext", current_id, name.GetCString());
|
||||
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for '%s' in a NULL DeclContext", current_id, name.GetCString());
|
||||
else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context))
|
||||
log->Printf("FindExternalVisibleDecls[%u] for '%s' in '%s'", current_id, name.GetCString(), context_named_decl->getNameAsString().c_str());
|
||||
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for '%s' in '%s'", current_id, name.GetCString(), context_named_decl->getNameAsString().c_str());
|
||||
else
|
||||
log->Printf("FindExternalVisibleDecls[%u] for '%s' in a '%s'", current_id, name.GetCString(), context.m_decl_context->getDeclKindName());
|
||||
log->Printf("ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for '%s' in a '%s'", current_id, name.GetCString(), context.m_decl_context->getDeclKindName());
|
||||
}
|
||||
|
||||
context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap);
|
||||
|
||||
|
||||
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
|
||||
{
|
||||
ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context);
|
||||
|
||||
if (log && log->GetVerbose())
|
||||
log->Printf(" FEVD[%u] Inspecting namespace map %p (%d entries)",
|
||||
log->Printf(" CEDM::FEVD[%u] Inspecting namespace map %p (%d entries)",
|
||||
current_id,
|
||||
namespace_map.get(),
|
||||
(int)namespace_map->size());
|
||||
|
@ -2180,7 +2178,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
|
|||
++i)
|
||||
{
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Searching namespace %s in module %s",
|
||||
log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s",
|
||||
current_id,
|
||||
i->second.GetNamespaceDecl()->getNameAsString().c_str(),
|
||||
i->first->GetFileSpec().GetFilename().GetCString());
|
||||
|
@ -2188,7 +2186,6 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
|
|||
FindExternalVisibleDecls(context,
|
||||
i->first,
|
||||
i->second,
|
||||
name,
|
||||
current_id);
|
||||
}
|
||||
}
|
||||
|
@ -2202,50 +2199,37 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context)
|
|||
ClangNamespaceDecl namespace_decl;
|
||||
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Searching the root namespace", current_id);
|
||||
log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id);
|
||||
|
||||
FindExternalVisibleDecls(context,
|
||||
lldb::ModuleSP(),
|
||||
namespace_decl,
|
||||
name,
|
||||
current_id);
|
||||
}
|
||||
|
||||
if (!context.m_namespace_map->empty())
|
||||
{
|
||||
if (log && log->GetVerbose())
|
||||
log->Printf(" FEVD[%u] Registering namespace map %p (%d entries)",
|
||||
current_id,
|
||||
context.m_namespace_map.get(),
|
||||
(int)context.m_namespace_map->size());
|
||||
|
||||
NamespaceDecl *clang_namespace_decl = AddNamespace(context, context.m_namespace_map);
|
||||
|
||||
if (clang_namespace_decl)
|
||||
clang_namespace_decl->setHasExternalVisibleStorage();
|
||||
}
|
||||
if (!context.m_found.variable)
|
||||
ClangASTSource::FindExternalVisibleDecls(context);
|
||||
}
|
||||
|
||||
void
|
||||
ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
||||
lldb::ModuleSP module_sp,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
const ConstString &name,
|
||||
unsigned int current_id)
|
||||
{
|
||||
assert (m_struct_vars.get());
|
||||
assert (m_parser_vars.get());
|
||||
assert (m_ast_context);
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
|
||||
SymbolContextList sc_list;
|
||||
|
||||
const ConstString name(context.m_decl_name.getAsString().c_str());
|
||||
|
||||
const char *name_unique_cstr = name.GetCString();
|
||||
|
||||
if (name_unique_cstr == NULL)
|
||||
return;
|
||||
|
||||
|
||||
// Only look for functions by name out in our symbols if the function
|
||||
// doesn't start with our phony prefix of '$'
|
||||
Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
|
||||
|
@ -2280,7 +2264,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
|
||||
if (log && log->GetVerbose())
|
||||
{
|
||||
log->Printf (" FEVD[%u] Type for \"this\" is: ", current_id);
|
||||
log->Printf (" CEDM::FEVD[%u] Type for \"this\" is: ", current_id);
|
||||
StreamString strm;
|
||||
this_type->Dump(&strm, true);
|
||||
log->PutCString (strm.GetData());
|
||||
|
@ -2308,7 +2292,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
if (log)
|
||||
{
|
||||
ASTDumper ast_dumper(pointer_target_qual_type);
|
||||
log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString());
|
||||
}
|
||||
|
||||
AddOneType(context, class_user_type, current_id, true);
|
||||
|
@ -2402,7 +2386,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
break;
|
||||
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Found persistent type %s", current_id, name.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%u] Found persistent type %s", current_id, name.GetCString());
|
||||
|
||||
context.AddNamedDecl(parser_ptype_type_decl);
|
||||
} while (0);
|
||||
|
@ -2420,11 +2404,11 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
if (m_parser_vars->m_exe_ctx->GetRegisterContext())
|
||||
{
|
||||
const RegisterInfo *reg_info(m_parser_vars->m_exe_ctx->GetRegisterContext()->GetRegisterInfoByName(reg_name));
|
||||
|
||||
|
||||
if (reg_info)
|
||||
{
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Found register %s", current_id, reg_info->name);
|
||||
log->Printf(" CEDM::FEVD[%u] Found register %s", current_id, reg_info->name);
|
||||
|
||||
AddOneRegister(context, reg_info, current_id);
|
||||
}
|
||||
|
@ -2549,103 +2533,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (module_sp && namespace_decl)
|
||||
{
|
||||
ClangNamespaceDecl found_namespace_decl;
|
||||
|
||||
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
|
||||
|
||||
if (symbol_vendor)
|
||||
{
|
||||
SymbolContext null_sc;
|
||||
|
||||
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
||||
|
||||
if (found_namespace_decl)
|
||||
{
|
||||
context.m_namespace_map->push_back(std::pair<ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
|
||||
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Found namespace %s in module %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
module_sp->GetFileSpec().GetFilename().GetCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleList &images = m_parser_vars->m_sym_ctx.target_sp->GetImages();
|
||||
|
||||
for (uint32_t i = 0, e = images.GetSize();
|
||||
i != e;
|
||||
++i)
|
||||
{
|
||||
ModuleSP image = images.GetModuleAtIndex(i);
|
||||
|
||||
if (!image)
|
||||
continue;
|
||||
|
||||
ClangNamespaceDecl found_namespace_decl;
|
||||
|
||||
SymbolVendor *symbol_vendor = image->GetSymbolVendor();
|
||||
|
||||
if (!symbol_vendor)
|
||||
continue;
|
||||
|
||||
SymbolContext null_sc;
|
||||
|
||||
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
||||
|
||||
if (found_namespace_decl)
|
||||
{
|
||||
context.m_namespace_map->push_back(std::pair<ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
|
||||
|
||||
if (log)
|
||||
log->Printf(" FEVD[%u] Found namespace %s in module %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
image->GetFileSpec().GetFilename().GetCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ConstString id_name("id");
|
||||
|
||||
do
|
||||
{
|
||||
TypeList types;
|
||||
SymbolContext null_sc;
|
||||
|
||||
if (module_sp && namespace_decl)
|
||||
module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types);
|
||||
else if(name != id_name)
|
||||
target->GetImages().FindTypes (null_sc, name, true, 1, types);
|
||||
else
|
||||
break;
|
||||
|
||||
if (types.GetSize())
|
||||
{
|
||||
TypeSP type_sp = types.GetTypeAtIndex(0);
|
||||
|
||||
if (log)
|
||||
{
|
||||
const char *name_string = type_sp->GetName().GetCString();
|
||||
|
||||
log->Printf(" FEVD[%u] Matching type found for \"%s\": %s",
|
||||
current_id,
|
||||
name.GetCString(),
|
||||
(name_string ? name_string : "<anonymous>"));
|
||||
}
|
||||
|
||||
TypeFromUser user_type(type_sp->GetClangFullType(),
|
||||
type_sp->GetClangAST());
|
||||
|
||||
AddOneType(context, user_type, current_id, false);
|
||||
}
|
||||
} while(0);
|
||||
}
|
||||
|
||||
Value *
|
||||
|
@ -2812,7 +2700,7 @@ ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP v
|
|||
if (log)
|
||||
{
|
||||
ASTDumper ast_dumper(var_decl);
|
||||
log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2841,7 +2729,7 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
|
|||
if (log)
|
||||
{
|
||||
ASTDumper ast_dumper(var_decl);
|
||||
log->Printf(" FEVD[%u] Added pvar %s, returned %s", current_id, pvar_sp->GetName().GetCString(), ast_dumper.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%u] Added pvar %s, returned %s", current_id, pvar_sp->GetName().GetCString(), ast_dumper.GetCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2899,7 +2787,7 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
|
|||
{
|
||||
ASTDumper ast_dumper(var_decl);
|
||||
|
||||
log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2994,7 +2882,7 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
|
|||
if (log && log->GetVerbose())
|
||||
{
|
||||
ASTDumper ast_dumper(var_decl);
|
||||
log->Printf(" FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), ast_dumper.GetCString());
|
||||
log->Printf(" CEDM::FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), ast_dumper.GetCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3092,7 +2980,7 @@ ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
|
|||
{
|
||||
ASTDumper ast_dumper(fun_decl);
|
||||
|
||||
log->Printf(" FEVD[%u] Found %s function %s, returned %s",
|
||||
log->Printf(" CEDM::FEVD[%u] Found %s function %s, returned %s",
|
||||
current_id,
|
||||
(fun ? "specific" : "generic"),
|
||||
decl_name.c_str(),
|
||||
|
@ -3110,9 +2998,7 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
|
|||
ASTContext *user_ast_context = ut.GetASTContext();
|
||||
|
||||
void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
|
||||
|
||||
TypeFromParser parser_type(copied_type, parser_ast_context);
|
||||
|
||||
|
||||
if (add_method && ClangASTContext::IsAggregateType(copied_type))
|
||||
{
|
||||
void *args[1];
|
||||
|
@ -3144,21 +3030,3 @@ ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
|
|||
|
||||
context.AddTypeDecl(copied_type);
|
||||
}
|
||||
|
||||
void *
|
||||
ClangExpressionDeclMap::GuardedCopyType (ASTContext *dest_context,
|
||||
ASTContext *source_context,
|
||||
void *clang_type)
|
||||
{
|
||||
assert (m_parser_vars.get());
|
||||
|
||||
m_parser_vars->m_ignore_lookups = true;
|
||||
|
||||
QualType ret_qual_type = m_ast_importer->CopyType (source_context, QualType::getFromOpaquePtr(clang_type));
|
||||
|
||||
void *ret = ret_qual_type.getAsOpaquePtr();
|
||||
|
||||
m_parser_vars->m_ignore_lookups = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue