mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 09:31:59 +08:00
Moved FindExternalLexicalDecls and a few smaller
functions from ClangExpressionDeclMap to ClangASTSource. llvm-svn: 143276
This commit is contained in:
@@ -2648,143 +2648,6 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
||||
} while(0);
|
||||
}
|
||||
|
||||
clang::ExternalLoadResult
|
||||
ClangExpressionDeclMap::FindExternalLexicalDecls (const DeclContext *decl_context,
|
||||
bool (*predicate)(Decl::Kind),
|
||||
llvm::SmallVectorImpl<Decl*> &decls)
|
||||
{
|
||||
assert (m_parser_vars.get());
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
const Decl *context_decl = dyn_cast<Decl>(decl_context);
|
||||
|
||||
if (!context_decl)
|
||||
return ELR_Failure;
|
||||
|
||||
static unsigned int invocation_id = 0;
|
||||
unsigned int current_id = invocation_id++;
|
||||
|
||||
if (log)
|
||||
{
|
||||
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
|
||||
log->Printf("FindExternalLexicalDecls[%u] in '%s' (a %s) with %s predicate",
|
||||
current_id,
|
||||
context_named_decl->getNameAsString().c_str(),
|
||||
context_decl->getDeclKindName(),
|
||||
(predicate ? "non-null" : "null"));
|
||||
else if(context_decl)
|
||||
log->Printf("FindExternalLexicalDecls[%u] in a %s with %s predicate",
|
||||
current_id,
|
||||
context_decl->getDeclKindName(),
|
||||
(predicate ? "non-null" : "null"));
|
||||
else
|
||||
log->Printf("FindExternalLexicalDecls[%u] in a NULL context with %s predicate",
|
||||
current_id,
|
||||
(predicate ? "non-null" : "null"));
|
||||
}
|
||||
|
||||
Decl *original_decl = NULL;
|
||||
ASTContext *original_ctx = NULL;
|
||||
|
||||
if (!m_ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx))
|
||||
return ELR_Failure;
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf(" FELD[%u] Original decl:", current_id);
|
||||
ASTDumper(original_decl).ToLog(log, " ");
|
||||
}
|
||||
|
||||
if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl))
|
||||
{
|
||||
ExternalASTSource *external_source = original_ctx->getExternalSource();
|
||||
|
||||
if (external_source)
|
||||
external_source->CompleteType (original_tag_decl);
|
||||
}
|
||||
|
||||
DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl);
|
||||
|
||||
if (!original_decl_context)
|
||||
return ELR_Failure;
|
||||
|
||||
for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
|
||||
iter != original_decl_context->decls_end();
|
||||
++iter)
|
||||
{
|
||||
Decl *decl = *iter;
|
||||
|
||||
if (!predicate || predicate(decl->getKind()))
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
ASTDumper ast_dumper(decl);
|
||||
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
|
||||
log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString());
|
||||
else
|
||||
log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString());
|
||||
}
|
||||
|
||||
Decl *copied_decl = m_ast_importer->CopyDecl(original_ctx, decl);
|
||||
|
||||
decls.push_back(copied_decl);
|
||||
}
|
||||
}
|
||||
|
||||
return ELR_AlreadyLoaded;
|
||||
}
|
||||
|
||||
void
|
||||
ClangExpressionDeclMap::CompleteType (TagDecl *tag_decl)
|
||||
{
|
||||
assert (m_parser_vars.get());
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf(" [CompleteTagDecl] Completing a TagDecl named %s", tag_decl->getName().str().c_str());
|
||||
log->Printf(" [CTD] Before:");
|
||||
ASTDumper dumper((Decl*)tag_decl);
|
||||
dumper.ToLog(log, " [CTD] ");
|
||||
}
|
||||
|
||||
m_ast_importer->CompleteTagDecl (tag_decl);
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf(" [CTD] After:");
|
||||
ASTDumper dumper((Decl*)tag_decl);
|
||||
dumper.ToLog(log, " [CTD] ");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClangExpressionDeclMap::CompleteType (clang::ObjCInterfaceDecl *interface_decl)
|
||||
{
|
||||
assert (m_parser_vars.get());
|
||||
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf(" [CompleteObjCInterfaceDecl] Completing an ObjCInterfaceDecl named %s", interface_decl->getName().str().c_str());
|
||||
log->Printf(" [COID] Before:");
|
||||
ASTDumper dumper((Decl*)interface_decl);
|
||||
dumper.ToLog(log, " [COID] ");
|
||||
}
|
||||
|
||||
m_ast_importer->CompleteObjCInterfaceDecl (interface_decl);
|
||||
|
||||
if (log)
|
||||
{
|
||||
log->Printf(" [COID] After:");
|
||||
ASTDumper dumper((Decl*)interface_decl);
|
||||
dumper.ToLog(log, " [COID] ");
|
||||
}
|
||||
}
|
||||
|
||||
Value *
|
||||
ClangExpressionDeclMap::GetVariableValue
|
||||
(
|
||||
@@ -3031,7 +2894,6 @@ ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
|
||||
entity->m_parser_vars->m_llvm_value = NULL;
|
||||
entity->m_parser_vars->m_lldb_value = symbol_location.release();
|
||||
entity->m_parser_vars->m_lldb_sym = &symbol;
|
||||
//entity->m_flags |= ClangExpressionVariable::EVUnknownType;
|
||||
|
||||
if (log)
|
||||
{
|
||||
@@ -3136,27 +2998,6 @@ ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
|
||||
}
|
||||
}
|
||||
|
||||
NamespaceDecl *
|
||||
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_ast_importer->CopyDecl(namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl());
|
||||
|
||||
NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
|
||||
|
||||
m_ast_importer->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
|
||||
|
||||
return dyn_cast<NamespaceDecl>(copied_decl);
|
||||
}
|
||||
|
||||
void
|
||||
ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
|
||||
Function* fun,
|
||||
|
||||
Reference in New Issue
Block a user