forked from OSchip/llvm-project
Added a function to ClangASTSource to service
lookups for Objective-C methods by selector. Right now all it does is print log information. Also improved the logging for imported TagDecls to indicate whether or not the definition for the imported TagDecl is complete. llvm-svn: 144203
This commit is contained in:
parent
5d9ae5ca23
commit
0730e9c992
|
@ -278,6 +278,17 @@ protected:
|
|||
lldb::ModuleSP module,
|
||||
ClangNamespaceDecl &namespace_decl,
|
||||
unsigned int current_id);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Find all Objective-C methods matching a given selector.
|
||||
///
|
||||
/// @param[in] context
|
||||
/// The NameSearchContext that can construct Decls for this name.
|
||||
/// Its m_decl_name contains the selector and its m_decl_context
|
||||
/// is the containing object.
|
||||
//------------------------------------------------------------------
|
||||
void
|
||||
FindObjCMethodDecls (NameSearchContext &context);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// A wrapper for ClangASTContext::CopyType that sets a flag that
|
||||
|
|
|
@ -72,12 +72,18 @@ ClangASTSource::FindExternalVisibleDeclsByName
|
|||
case DeclarationName::CXXUsingDirective:
|
||||
return SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
|
||||
|
||||
// These aren't looked up like this.
|
||||
case DeclarationName::ObjCZeroArgSelector:
|
||||
case DeclarationName::ObjCOneArgSelector:
|
||||
case DeclarationName::ObjCMultiArgSelector:
|
||||
return DeclContext::lookup_result();
|
||||
{
|
||||
llvm::SmallVector<NamedDecl*, 1> method_decls;
|
||||
|
||||
NameSearchContext method_search_context (*this, method_decls, clang_decl_name, decl_ctx);
|
||||
|
||||
FindObjCMethodDecls(method_search_context);
|
||||
|
||||
return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, method_decls);
|
||||
}
|
||||
// These aren't possible in the global context.
|
||||
case DeclarationName::CXXConstructorName:
|
||||
case DeclarationName::CXXDestructorName:
|
||||
|
@ -457,6 +463,46 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
|
|||
} while(0);
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::FindObjCMethodDecls (NameSearchContext &context)
|
||||
{
|
||||
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
const DeclarationName &decl_name(context.m_decl_name);
|
||||
const DeclContext *decl_ctx(context.m_decl_context);
|
||||
|
||||
const ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl_ctx);
|
||||
|
||||
if (!interface_decl)
|
||||
return;
|
||||
|
||||
StreamString ss;
|
||||
if (decl_name.isObjCZeroArgSelector())
|
||||
{
|
||||
ss.Printf("%s", decl_name.getAsString().c_str());
|
||||
}
|
||||
else if (decl_name.isObjCOneArgSelector())
|
||||
{
|
||||
ss.Printf("%s:", 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);
|
||||
ss.Printf("%s:", r.str().c_str());
|
||||
}
|
||||
}
|
||||
ss.Flush();
|
||||
|
||||
if (log)
|
||||
log->Printf("ClangASTSource::FindObjCMethodDecls for selector [%s %s]", interface_decl->getNameAsString().c_str(), ss.GetData());
|
||||
}
|
||||
|
||||
void
|
||||
ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map,
|
||||
const ConstString &name,
|
||||
|
|
|
@ -165,12 +165,16 @@ clang::Decl
|
|||
TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
|
||||
|
||||
to_tag_decl->setHasExternalLexicalStorage();
|
||||
|
||||
|
||||
if (log)
|
||||
log->Printf(" [ClangASTImporter] Imported a TagDecl named %s%s%s",
|
||||
log->Printf(" [ClangASTImporter] Imported %p, a %s named %s%s%s [%s->%s]",
|
||||
to,
|
||||
((clang::Decl*)from_tag_decl)->getDeclKindName(),
|
||||
from_tag_decl->getName().str().c_str(),
|
||||
(to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
|
||||
(to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""));
|
||||
(to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
|
||||
(from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
|
||||
(to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
|
||||
}
|
||||
|
||||
if (isa<NamespaceDecl>(from))
|
||||
|
@ -186,6 +190,8 @@ clang::Decl
|
|||
{
|
||||
ObjCInterfaceDecl *to_interface_decl = dyn_cast<ObjCInterfaceDecl>(to);
|
||||
|
||||
to_interface_decl->setHasExternalVisibleStorage();
|
||||
|
||||
if (!to_interface_decl->isForwardDecl())
|
||||
to_interface_decl->setExternallyCompleted();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue